Skip to content

@nx/vitest - Migrations

The @nx/vitest plugin provides various migrations to help you migrate to newer versions of vitest projects within your Nx workspace. Below is a complete reference for all available migrations.

update-23-0-0-migrate-create-nodes-v2-import

Section titled “update-23-0-0-migrate-create-nodes-v2-import”

Version: 23.0.0-beta.24

Rename imports of createNodesV2 from @nx/vitest to the canonical createNodes export.

Rename createNodesV2 imports to createNodes

Section titled “Rename createNodesV2 imports to createNodes”

@nx/vitest renamed its primary inferred-plugin export from createNodesV2 to createNodes. The createNodesV2 name is preserved as a deprecated alias for now, but new code should use createNodes.

This migration scans every .ts, .tsx, .cts, and .mts file in your workspace and rewrites named imports and re-exports of createNodesV2 from @nx/vitestst to createNodes.

import { createNodesV2 } from '@nx/vitestst';
import { createNodes } from '@nx/vitestst';

Aliases are preserved (createNodesV2 as cn becomes createNodes as cn), and if a file already imports both names ({ createNodes, createNodesV2 }) the redundant binding is dropped.

Only static import/export named bindings from @nx/vitestst are rewritten. Namespace imports, dynamic import(...), require(...) destructuring, and property access such as plugin.createNodesV2 are left untouched — they keep working through the createNodesV2 runtime alias. Update those by hand if you want to drop the deprecated name everywhere.

Version: 23.0.1

The following packages will be updated:

NameVersionAlways add to package.json
happy-dom^20.10.4Updated only

Version: 22.6.0-beta.11

Prefix reportsDirectory with {projectRoot} to maintain correct resolution after workspace-root-relative behavior change.

Prefix reportsDirectory with {projectRoot}

Section titled “Prefix reportsDirectory with {projectRoot}”

The reportsDirectory option for @nx/vitest:test (and @nx/vite:test) is now resolved relative to the workspace root instead of the project root. This migration prepends {projectRoot}/ to existing reportsDirectory values so the resolved path remains the same.

project.json
{
"targets": {
"test": {
"executor": "@nx/vitest:test",
"options": {
"reportsDirectory": "coverage/libs/my-lib"
}
}
}
}
project.json
{
"targets": {
"test": {
"executor": "@nx/vitest:test",
"options": {
"reportsDirectory": "{projectRoot}/coverage/libs/my-lib"
}
}
}
}

Version: 22.3.2-beta.0

Create AI Instructions to help migrate users workspaces past breaking changes for Vitest 4.

NameVersion
@angular/build>=21.0.0
vitest>=4.0.0

Version: 22.3.2-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
vitest^4.0.8Updated only
@vitest/coverage-v8^4.0.8Updated only
@vitest/coverage-istanbul^4.0.8Updated only
@vitest/ui^4.0.8Updated only
jsdom^27.1.0Updated only

Version: 22.3.2-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
@analogjs/vite-plugin-angular~2.2.0Updated only
@analogjs/vitest-angular~2.2.0Updated only

Version: 22.2.0-beta.3

The following packages will be updated:

NameVersionAlways add to package.json
@analogjs/vite-plugin-angular~2.1.2Updated only
@analogjs/vitest-angular~2.1.2Updated only

Version: 22.1.0-beta.8

Create AI Instructions to help migrate users workspaces past breaking changes for Vitest 4.

NameVersion
vitest>=4.0.0

Version: 22.1.0-beta.8

The following packages will be updated:

NameVersionAlways add to package.json
vitest^4.0.0Updated only
@vitest/coverage-v8^4.0.0Updated only
@vitest/coverage-istanbul^4.0.0Updated only
@vitest/ui^4.0.0Updated only