1.4 KiB
1.4 KiB
| title | description |
|---|---|
| Examples for the Vitest executor | This page contains examples for the Vitest @nx/vite:test executor. |
project.json:
//...
"my-app": {
"targets": {
//...
"test": {
"executor": "@nx/vite:test",
//...
//...
"options": {
"config": "apps/my-app/vite.config.ts"
}
//...
}
}
}
nx test my-app
Examples
{% tabs %}
{% tab label="Running in watch mode" %} To run testing in watch mode, you can create a new configuration within your test target, and have watch set to true. For example:
"my-app": {
"targets": {
//...
"test": {
"executor": "@nx/vite:test",
//...
//...
"options": {
"config": "apps/my-app/vite.config.ts"
},
"configurations": {
"watch": {
"watch": true
}
}
}
}
}
And then run nx run my-app:test:watch.
Alternatively, you can just run the default test target with the --watch flag preset, like so:
nx run my-app:test --watch
{% /tab %} {% tab label="Updating snapshots" %} Whenever a test fails because of an outdated snapshot, you can tell vitest to update them with the following:
nx run my-app:test -u
{% /tab %}
{% /tabs %}