NX
Running cypress tests in parallel with Currents for NX projects

Running cypress tests in NX project with Currents

Nx is a next generation build system with first class monorepo support and powerful integrations. You can run cypress tests on Currents using @currents/nx plugin and defining a few configuration options.

How to setup cypress tests in NX project

First, install @currens/nx npm package.
1
npm i --save-dev @currents/nx
Copied!
Add currents target to your project configuration.
1
{
2
// ...
3
"targets": {
4
"currents": {
5
"executor": "@currents/nx:currents",
6
"options": {
7
"cypressExecutor": "e2e" // target name that runs "@nrwl/cypress:cypress"
8
}
9
},
10
"e2e"
11
"executor": "@nrwl/cypress:cypress",
12
"options": {
13
// record: true,
14
// parallel: true,
15
// key: "currents dashboard key"
16
// ...
17
},
18
"configurations": {
19
// ...
20
}
21
}
22
}
23
// ...
Copied!
Run cypress tests using Currents dashboard service
1
nx run project:currents --record --key <key> --ci-build-id hello-currents-nx -- --parallel
Copied!
Please note the use of -- --parallel flag due to conflicts with existing NX flags. See #8014, #1604
  • The plugin requires an already installed @nrwl/cypress and a configured target that's running @nrwl/cypress:cypress
  • @currents/nx:currents will run @nrwl/cypress:cypress behind the scenes
  • You can set predefined options in target definition
  • Update your cypress.json file with projectId obtained from https://app.currents.dev
  • Use the record key obtained from https://app.currents.dev
You can also omit CLI flags and instead provide cypress options within @nrwl/cypress:cypress executor's options, for example:
1
// ...
2
"currents": {
3
"executor": "@currents/nx:currents",
4
"options": {
5
"cypressExecutor": "e2e"
6
}
7
},
8
"e2e": {
9
"executor": "@nrwl/cypress:cypress",
10
"options": {
11
"cypressConfig": "apps/frontend-e2e/cypress.json",
12
"devServerTarget": "frontend:serve",
13
"record": true,
14
"parallel": true,
15
"key": "currents key"
16
},
17
"configurations": {
18
"production": {
19
"devServerTarget": "frontend:serve:production"
20
}
21
}
22
}
23
// ...
Copied!
See our example repo at https://github.com/currents-dev/currents-nx-example for integration details.