This repository shows how to use NX + Playwright with Currents.
npm i -g nx@latest
npm i
The repo has two projects and each has its own tests.
CURRENTS_RECORD_KEY=recordkey \
CURRENTS_PROJECT_ID=projectid \
CURRENTS_CI_BUILD_ID=`date +%s` \
nx run-many -t e2e --parallel=2 --verbose
# ...
NX Running target e2e for 2 projects
→ Executing 2/2 remaining tasks in parallel...
⠙ nx run e2e-01:e2e
⠙ nx run e2e-02:e2e
# ...
NX Ran target e2e for 2 projects (8s)
✔ 1/2 succeeded [0 read from cache]
✖ 1/2 targets failed, including the following:
- nx run e2e-01:e2e
Playwright output directory is set in project.json
> targets.e2e.options.output
, for example:
"targets": {
"e2e": {
"executor": "@nx/playwright:playwright",
"options": {
"skipInstall": true,
"output": "{workspaceRoot}/playwright-report/{projectName}",
"config": "{projectRoot}/playwright.config.ts"
}
}
}
After running the tests, results will appear as:
playwright-report/
├── e2e-01/
│ └── .last-run.json
└── e2e-02/
└── .last-run.json
ℹ️ playwright.config.ts
for each project use nxE2EPreset
- it sets a different output
directory, but project.json:output
overrides it.
nx passes down unrecognized arguments to the target command, for example
nx run-many -t e2e --parallel=2 --verbose --last-failed
# ...
NX Ran target e2e for 2 projects (7s)
With additional flags:
--last-failed=true
# ...
NX Ran target e2e for 2 projects (7s)
With additional flags:
--last-failed=true
✔ 1/2 succeeded [0 read from cache]
✖ 1/2 targets failed, including the following:
- nx run e2e-01:e2e
The project named e2e-03
has a different target than the other two projects. The target is or8n
This target project executes pwc-p
command. When using it in multiple machines it will execute in parallel the tests of this project.
CURRENTS_RECORD_KEY=recordkey \
CURRENTS_PROJECT_ID=projectid \
CURRENTS_CI_BUILD_ID=`date +%s` \
nx run-many -t or8n
# ...
NX Running target or8n for 1 project
⠙ nx run e2e-03:or8n
The parallel
flag is no longer needed as it is running a single nx project.
The or8n.yml
file has an example for running it in Github actions.