project.json:

1//... 2"my-app": { 3 "targets": { 4 //... 5 "test": { 6 "executor": "@nx/vite:test", 7 //... 8 //... 9 "options": { 10 "config": "apps/my-app/vite.config.ts" 11 } 12 //... 13 } 14 } 15} 16
1nx test my-app 2

Examples

To run testing in watch mode, you can create a new configuration within your test target, and have watch set to true. For example:

1"my-app": { 2 "targets": { 3 //... 4 "test": { 5 "executor": "@nx/vite:test", 6 //... 7 //... 8 "options": { 9 "config": "apps/my-app/vite.config.ts" 10 }, 11 "configurations": { 12 "watch": { 13 "watch": true 14 } 15 } 16 } 17 } 18} 19

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:

1nx run my-app:test --watch 2

Options

configFile

string

The path to the local vitest config

mode

string

Mode for Vite.

reportsDirectory

string

Directory to write coverage report to.

testFiles

Array<string>

No description available.

watch

boolean

Watch files for changes and rerun tests related to changed files.