Nx: E2E tests can't be ran in parallel

Created on 21 Jul 2019  路  11Comments  路  Source: nrwl/nx

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:

Screen Shot 2019-07-20 at 4 23 32 PM

Protractor:

Screen Shot 2019-07-20 at 4 28 24 PM

Steps to Reproduce

  1. Generate a Nx workspace
  2. Generate either two Cypress or two Protractor projects
  3. npm run affected:e2e -- --all --parallel

Context

  • version of Nx used 8.2.0
testing tools bug

Most helpful comment

Without having looked at it, this _may_ work though as it is right now.
nx affected:e2e --parallel --maxParallel=2 -- --parallel where the second --parallel gets passed along to the individual cypress run for the affected application.

I can verify that this approach (adding -- --parallel) fixes our problems with the --parallel flag being eaten by nx, and not passed to cypress.

All 11 comments

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:

node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng e2e paldesk-e2e --browser=chrome --record=true --ci-build-id= --ciBuildId= --group=Azure CI Unknown option: '--ci-build-id' Unknown option: '--ciBuildId' Unknown option: '--group' Unknown option: 'CI' error Command failed with exit code 1.

In AzureDevops

This is interesting because of the way the --parallel flag 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. 馃

Hi, sorry about this.

This was mislabeled as stale. We are testing ways to mark _not reproducible_ issues as stale so that we can focus on actionable items but our initial experiment was too broad and unintentionally labeled this issue as stale.

Bump.

Any progress or updates on this @FrozenPandaz?

Just adding the piece of info that Cypress (with a paid plan) supports parallelization via the same --parallel flag, 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 -- --parallel where the second --parallel gets passed along to the individual cypress run for the affected application.
Cypress docs

Without having looked at it, this _may_ work though as it is right now.
nx affected:e2e --parallel --maxParallel=2 -- --parallel where the second --parallel gets passed along to the individual cypress run for the affected application.

I can verify that this approach (adding -- --parallel) fixes our problems with the --parallel flag being eaten by nx, and not passed to cypress.

@mike-park were you able to test this in a CI environment? And did you test with more than 1 app being affected?

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:

PS C:\MyApp> npx nx e2e myapp-e2e --headless

> ng run myapp-e2e:e2e --headless
Port 4200 is already in use. Use '--port' to specify a different port.

It says to specify a different port, but I don't get it to work:

PS C:\MyApp> npx nx e2e myapp-e2e --headless --port=0

> ng run myapp-e2e:e2e --headless --port=0 
Unknown option: '--port'

Is there any way to do this?

@wimme Each application should have it鈥檚 own localhost port If you create your apps with nx. You can than use affected command and parallel flag

@elvirdolic Then it's still not possible to run multiple CI pipelines simultaneously launching the same Cypress tests of the same application, or am I missing something?

As far I know, that鈥檚 not possible.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vimalraj-a picture vimalraj-a  路  3Comments

zpydee picture zpydee  路  3Comments

zachnewburgh picture zachnewburgh  路  3Comments

jon301 picture jon301  路  3Comments

ZempTime picture ZempTime  路  3Comments