@nrwl/jest:jest
Jest target options for Build Facade.
Options can be configured in project.json
when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.
Jest can be configured in many ways, but primarily you'll need to at least have the jestConfig options
1"test": {
2 "executor": "@nrwl/jest:jest",
3 "options": {
4 "jestConfig": "libs/my-lib/jest.config.ts"
5 }
6}
7
It is also helpful to have passWithNoTests: true
set so your project doesn't fail testing while tests are still being added.
1"test": {
2 "executor": "@nrwl/jest:jest",
3 "options": {
4 "jestConfig": "libs/my-lib/jest.config.ts",
5 "passWithNoTests": true
6 }
7}
8
Snapshots
Update snapshots running with --update-snapshot
or -u
for short.
nx test my-project -u
Other times you might not want to allow updating snapshots such as in CI. Adding a ci configuration is helpful for adding this behavior.
1"test": {
2 "executor": "@nrwl/jest:jest",
3 "options": {
4 "jestConfig": "libs/my-lib/jest.config.ts",
5 "passWithNoTests": true
6 },
7 "configurations": {
8 "ci": {
9 "ci": true
10 }
11 }
12}
13
nx affected --target=test --configuration=ci
Learn more about affected