nx: E2E tests can't be ran in parallel
Expected Behavior
E2E tests can be ran in parallel.
Current Behavior
E2E tests can’t be ran in parallel. Different errors are thrown based on the test runner.
Cypress:

Protractor:

Steps to Reproduce
- Generate a Nx workspace
- Generate either two Cypress or two Protractor projects
npm run affected:e2e -- --all --parallel
Context
- version of Nx used 8.2.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 22 (4 by maintainers)
Any news about this ?
I have the issue.
I can verify that this approach (adding
-- --parallel) fixes our problems with the--parallelflag being eaten by nx, and not passed to cypress.Have spent quite some time trying to get E2E tests running in parallel using Cypress Dashboard.
It works for single project target, splitting specs over multiple machines, but anything taking more projects such as
affected:e2efails either due to port in use, discrepancy in the capabilities (browser, version specs) sent to Cypress, group being closed or some issue with ngcc.Wonder if the --parallel flag should be removed from the e2e target until it is ready - otherwise at least some improvement of the docs would be nice to be clear exactly when and how it can be used.
This is interesting because of the way the
--parallelflag works.It essentially creates new processes and lets them do their thing. It has no way of knowing the context of the process that should be spawned. In the case of Cypress (or anything else that could potentially spin up a server that listens on a port), all processes try to get access to the same port.
We could potentially make the cypress builder a bit smarter and check to see if the port is available before starting it. 🤔
We would like to run multiple Cypress instances simultaneously on our CI environment to test different applications in the Nx workspace in parallel. But as described above, it fails when launching multiple as the port is already in use:
It says to specify a different port, but I don’t get it to work:
Is there any way to do this?
Just adding the piece of info that Cypress (with a paid plan) supports parallelization via the same
--parallelflag, so a way to differentiate between the two may be necessary.Without having looked at it, this may work though as it is right now.
nx affected:e2e --parallel --maxParallel=2 -- --parallelwhere the second--parallelgets passed along to the individual cypress run for the affected application. Cypress docssemi-related #8286
for now, cypress doesn’t know what ports are/aren’t available as @Cammisuli this might be something we can make the cypress executor look into. the safest way to prevent this is going to be running nx with --parallel=1 to prevent the processes from reaching for the same port. or to change the port in which the apps are served on in each project being used in cypress
as others have mentioned you can pass the
-- --parallelflag to get that flag to cypress if needed. closing for now.I also had issues with this. I was able to use “dash dash” to pass parallel as params. My full command to running parallelized tests in gitlab CI is below.
In my situation…In order to get parallel tests to work, I also had to pass the
--ci-build-idby hand. It seems that NX is not allowing cypress to determine this automatically as discussed here:I would also like to run cypress e2e in parallel but adding following command
yarn affected:e2e --base=origin/master --head=HEAD --browser chrome --record --parallel --ci-build-id $BUILD_BUILDNUMBER --group "Azure CI"The result is following: