Skip to content

Vitest functionality has been split from @nx/vite into a standalone @nx/vitest package. This provides better separation of concerns and allows vitest to be used independently of vite.

  • @nx/vite:vitest@nx/vitest:configuration
  • @nx/vite:test@nx/vitest:test
  • @nx/vite/plugin (for vitest) → @nx/vitest
Terminal window
npm install --save-dev @nx/vitest
# or
pnpm add -D @nx/vitest
# or
yarn add -D @nx/vitest

Before:

{
"targets": {
"test": {
"executor": "@nx/vite:test",
"options": {
"config": "vite.config.ts"
}
}
}
}

After:

{
"targets": {
"test": {
"executor": "@nx/vitest:test",
"options": {
"config": "vite.config.ts"
}
}
}
}

Before:

{
"plugins": [
{
"plugin": "@nx/vite/plugin",
"options": {
"testTargetName": "test"
}
}
]
}

After:

{
"plugins": [
{
"plugin": "@nx/vitest",
"options": {
"testTargetName": "test"
}
}
]
}

When adding vitest to new projects:

Terminal window
# Old
nx g @nx/vite:vitest my-project
# New
nx g @nx/vitest:configuration my-project

The old @nx/vite:vitest generator and @nx/vite:test executor still work but are deprecated. They will be removed in Nx 23. Please migrate before upgrading to Nx 23.

When you use the deprecated generators/executors, you'll see a warning message:

The '@nx/vite:vitest' generator is deprecated. Please use '@nx/vitest:configuration' instead.
This generator will be removed in Nx 23.
  • vite.config.ts / vitest.config.ts: No changes needed
  • Test files: No changes needed
  • vitest.config.ts: No changes needed

File an issue at https://github.com/nrwl/nx/issues