@nrwl/vite:test

Test using Vitest.

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.

project.json:

//... "my-app": { "targets": { //... "test": { "executor": "@nrwl/vite:test", //... //... "options": { "config": "apps/my-app/vite.config.ts" } //... } } }
nx test my-app

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:

"my-app": { "targets": { //... "test": { "executor": "@nrwl/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

Options

config

string

The path to the local vitest config

coverage

boolean
Default: false

Enable coverage report

mode

string
Default: test
Accepted values: test, benchmark, typecheck

The mode that vitest will run on

passWithNoTests

boolean
Default: true

Pass the test even if no tests are found

reporters

Array<string>

An array of reporters to pass to vitest

testNamePattern

string

Run tests with full names matching the pattern

update

u
boolean
Default: false

Update snapshots

watch

boolean
Default: false

Enable watch mode