Open ChaseBig opened 5 years ago
First of all, I love the passion. Excellent use of rhetoric to communicate emotion.
Second of all, to make sure I understand, you want to run 3 Cypress instances simultaneously in the same CI container? And Xvfb is blocking that?
If that's the case, have you tried initializing Xvfb yourself? You can use xvfb-run
like this to do that:
cd packages/webApp1 && xvfb-run -a npm run cypress:run ...
cd packages/webApp2 && xvfb-run -a npm run cypress:run ...
cd packages/webApp3 && xvfb-run -a npm run cypress:run ...
This should work, because:
DISPLAY
set, andxvfb-run
with -a
makes it automatically use the next free server number, so you won't get the Error: Display :99 is already in use and the "reuse" option is false.
error.Let me know how this goes for you, I think it should work.
IMO, a better option would just be to create 3 parallel Circle jobs to run each test suite, then you wouldn't need to worry about any of this.
A long-term goal for Cypress is to reduce/remove the dependency on Xvfb, but that will require these things to be done first:
@flotwig Hi Zach!
Thank you so much for the quick and understanding reply (and for not calling me a complaining whiny baby lol).
As for your troubleshooting tips, I'm going to give the solutions a shot and will let you know how it goes!
I 100% agree on the parallel jobs, I'm working on getting that up-and-running as I learn more about how to do that. I really look forward to being able to do that!
Seriously, though, thank you for these suggestions! I'll keep ya posted.
If that's the case, have you tried initializing Xvfb yourself? You can use
xvfb-run
like this to do that:
So when I run $ cd packages/web.app-browser && xvfb-run -a yarn cypress run
, I get a bash: xvfb-run: command not found
error.
I have every xvfb related module I could find in every package.json of each package and in the project root.
xvfb
isn't a node module, it's a package for the X windowing system. Have you installed the dependencies required for Cypress? https://docs.cypress.io/guides/guides/continuous-integration.html#Dependencies
Specifically, apt install xvfb
will give you the xvfb-run
command.
Ahh, maybe that's my issue. I'm on macOS. i also cant get apt
, apt-get
, sudo apt-get
, yum
, or sudo yum
to work locally or on circleCi.
Since you are on CircleCI, can you try using either:
We run 1000s of tests per day on Circle, so it should be the simplest thing to do, in general.
Xvfb is only for running on Linux, you shouldn't need it for macOS. I'm not sure what your CI environment is like, but you can use our docker images that have all the dependencies preinstalled.
Okay sounds good. I will investigate that avenue instead of doing sketchy workarounds.
Thanks so much guys!
FWIW I think I solved this on a CentOS 8 box by spinning up the xvfb server externally:
/usr/bin/Xvfb :99 -screen 0 1920x1080x24+32 &
export DISPLAY=:99
At any rate, I have not had the issue since doing so.
I'm using a pipeline through bitbucket and I'm getting the same issue. Even if run the dependency from cypress:
apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
It is telling me that I have the same issue as the one that you have above with the xvfb package. Does anyone know a workaround?
I'm using a pipeline through bitbucket and I'm getting the same issue. Even if run the dependency from cypress:
apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
It is telling me that I have the same issue as the one that you have above with the xvfb package. Does anyone know a workaround?
I had to set the XVFB port for each individual package I was running tests against. They were all trying to use the same port on a single machine when running in parallel so i had to manually pass in a different port assignment because XVFB wasn't automatically assigning a new port if the port was already in use. I no longer work for the company I was building this for so I dont have code examples to show you, unfortunately.
Hi guys,
Sorry for jumping into this thread with a question that might be tagged as unrelated. I'm trying to run cypress in headed mode on CircleCI so that an extension I have installed (Metamask to be controlled using puppeteer) can be used but I have not found a single example or documentation to make my tests run xvfb which might be what my setup needs to run the tests in the same way they're running fine in my local machine runs.
Current CircleCI config is as follows:
version: 2.1
orbs:
cypress: cypress-io/cypress@1.28.0
codecov: codecov/codecov@1.1.3
executors:
with-chrome:
docker:
- image: "cypress/browsers:node14.16.0-chrome89-ff86"
resource_class: medium+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
commands:
report-coverage:
description: |
Store coverage report as an artifact and send it to Codecov service.
steps:
- store_artifacts:
path: coverage
- run: npx nyc report --reporter=text || true
- codecov/upload:
file: coverage/coverage-final.json
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Workflows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
linux-workflow: &linux-workflow
jobs:
# Setup
# 1. Install Cypress
# 2. Validate types
- cypress/install:
name: "Setup Linux"
yarn: true
build: "yarn"
executor: with-chrome
post-checkout:
- restore_cache:
keys:
- yarn-packages-v2-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-packages-v2-{{ .Branch }}-
- yarn-packages-v2-
cache-key: >-
cache-{{ checksum "package.json" }}
post-steps:
- save_cache:
key: yarn-packages-v2-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- node_modules
- run:
name: Print cache information
command: yarn cypress cache list
- run:
name: Check Types
command: yarn type-check:ci
# Run E2E tests in Chrome
- cypress/run:
command: yarn run cy:run:ci --ci-build-id ${CIRCLE_SHA1:0:8}
name: "UI Tests - Chrome"
executor: with-chrome
attach-workspace: true
start: yarn dev
wait-on: "http://localhost:8000"
yarn: true
parallelism: 5
cache-key: >-
cache-{{ checksum "package.json" }}
requires:
- Setup Linux
post-steps:
- report-coverage
workflows:
linux:
<<: *linux-workflow
Any help is truly appreciated!
This Issue title is hilarious. I screenshotted and sent it to several people. I received many "lol"s.
I find myself here, kackling with friends at the title, and crying because we are running into an issue with Xvfb, trying to automate a test for an application that does not run in a headless environment. I'm using it in conjunction with xdotool, but xdotool doesn't seem to be able to find the window.
It works with xvfb-run locally on my x11 popOS installation (i haven't changed anything about X either), but fails to find the window only in CI (Ubuntu Latest with recommended dependencies). Any help is appreciated!
How does one use this
reuse
option? Where do I set that? Do I create a new file or edit an existing one? The readme instructions are not very detailed. I am working in a monorepo that is simultaneously running three webApp environments each with their own cypress instances -- all running at the same time. I want to set each cypress instance to a different DISPLAY and then kill Xvfb after it's done. We are using CircleCi in a javascript/node.js codebase. We use acircle.yml
file to tell circleci what to do and when.This friggin' Xvfb stuff has literally wasted thousands of dollars worth of my time trying to fix.
Can anyone help me?
I get all kinds of random errors related to Xvfb failures.