feat(vitest): support vitest 5 by jaysoo · Pull Request #37142 · nrwl/nx · GitHub
Skip to content

feat(vitest): support vitest 5 - #37142

Merged
jaysoo merged 12 commits into
masterfrom
NXC-5032
Sep 29, 2026
Merged

jaysoo merged 12 commits into
masterfrom
NXC-5032

Conversation

@jaysoo

@jaysoo jaysoo commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Current Behavior

Generators template vitest ~4.1.0 and there is no migration path to v5.

Expected Behavior

New scaffolds default to vitest 5, with version selection falling back to the highest major the workspace can actually resolve. A hybrid migration moves existing workspaces.

Preview

https://deploy-preview-37142--nx-docs.netlify.app/docs/technologies/test-tools/vitest/introduction

Related Issue(s)

NXC-5032

@jaysoo jaysoo added the polygraph label Sep 22, 2026 — with Polygraph App
@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 2ae8743
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6abbba30f430e6000870458e
😎 Deploy Preview https://deploy-preview-37142--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 2ae8743

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ✅ Succeeded 35m 56s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 1m 7s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 35s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-29 13:57:13 UTC

@jaysoo
jaysoo marked this pull request as ready for review September 24, 2026 16:33
@jaysoo
jaysoo requested a review from a team as a code owner September 24, 2026 16:33
@jaysoo
jaysoo requested a review from AgentEnder September 24, 2026 16:33
nx-cloud[bot]

This comment was marked as outdated.

Generators template vitest `~4.1.0`. Peer range allows v5, nothing installs it. No migration path.

New scaffolds default to vitest 5. Version selection picks the highest major the workspace can resolve: vite >= 6.4 -> 5, vite >= 6.0 -> 4, vite 5 -> 3 (only major with no vite peer floor). `@analogjs/vitest-angular` caps at 4, it has no v5 peer.

Hybrid migration. Codemod does what has one answer: removed deep entry points, `.vitest` gitignore, and `vite` in package.json (v4 shipped it as a dep, v5 is peer-only). Context-dependent changes go to the paired prompt.

`nx-reporter.ts` moved off `vitest/reporters`, deleted in v5.

NXC-5032
## Current Behavior

Angular generators install vitest 5. `@angular/build` >= 21 skips the vitest pre-seed, so `@nx/vitest` picks the latest, and `@nx/angular` then rejects it against `^4.0.8`.

## Expected Behavior

Version selection takes the framework being configured, not just installed deps. Analog is added in the same pass, so it is not in package.json yet when the version is chosen.

## Related Issue(s)

NXC-5032
## Current Behavior

The codemod repoints `vitest/suite` and `vitest/runners` to modules that do not export their symbols, so migrated files no longer compile. Version selection caps Angular at vitest 4 only when nothing is installed yet and without intersecting the vite floor, and the migration gates miss `@angular/build` and the browser providers, which peer vitest 4.

## Expected Behavior

Rewrite a specifier only when every one of its v4 exports landed in one v5 module, and hand the rest to the paired prompt. Compute the framework cap before the installed-version branch, intersect it with the vite floor, and refuse an installed vitest the framework cannot take. Gate the package updates on `@angular/build` and the browser providers too.

Selection now takes the vite range rather than a major, so a `^6.9.0` workspace is no longer read as `6.0.0`. The migration declares the vite already resolved in the workspace instead of pinning 8.

## Related Issue(s)

NXC-5032
## Current Behavior

The version ladder is spread over three structures, and callers thread a `uiFramework` flag down so selection can predict a dependency the same pass is about to write. The migration reimplements the gitignore rule and reads and parses each file twice.

## Expected Behavior

The configuration generator writes the analog packages before init, so selection reads only `package.json` and the flag is gone. One ordered compat table replaces the vite floor map, the version map and the latest-versions record. `getInstalledViteVersion` returns undefined when vite is absent rather than reporting the default as installed, matching `@nx/vite`.

The migration reuses `addVitestTempFilesToGitIgnore`, visits each file once, and no longer reports an unrelated `sequential` member. `addVitestTempFilesToGitIgnore` appends instead of running `stripIndents` over the whole file.

## Related Issue(s)

NXC-5032
## Current Behavior

`updateGitIgnore` prepends a newline before every entry, so a workspace without a `.gitignore` gets one that opens with a blank line. `@nx/vitest` used to run `stripIndents` over the whole file afterwards, which hid it.

## Expected Behavior

The separator is only added between entries.

## Related Issue(s)

NXC-5032
## Current Behavior

A namespace import or a star re-export of a removed entry point is repointed without checking symbols, so `import * as reporters from 'vitest/reporters'` moves to `vitest/node`, which does not export everything it did. The `sequential` scan reports any property with that name, including unrelated application code.

## Expected Behavior

Only declarations that name their bindings are repointed; the rest go to the migration prompt. `sequential` is reported only in an options object passed to a test or suite call.

## Related Issue(s)

NXC-5032
jaysoo and others added 2 commits September 29, 2026 04:33
## Current Behavior

The Vitest requirements table lists a Node floor per Vitest major and says Nx pins none of its own. Nx 23 supports 26.x, 24.x and ^22.12.0, so a reader following the table to Node 18 for Vitest 3 or Node 20 for Vitest 4 lands on a runtime Nx does not support.

## Expected Behavior

The table carries the Vite requirement only, and Node support points at the Nx compatibility matrix.

## Related Issue(s)

NXC-5032
nx-cloud[bot]

This comment was marked as outdated.

@nx-cloud nx-cloud Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We traced the failure to a pre-existing environment mismatch, not to this PR's changes: the e2e helper hardcodes a yarn add -DW invocation that Yarn Berry (4.0.2, resolved via corepack) no longer supports. Since the PR only touches vitest/nuxt/vue/astro-docs code and never e2e/utils/command-utils.ts, we're treating this as an environment_state issue rather than something to fix in this PR.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

## Current Behavior

The intro paragraph links test splitting to `#ci-considerations`, which matches no heading on the page.

## Expected Behavior

It points at `#plugin-options`, where `ciTargetName` and the Atomizer are documented.

## Related Issue(s)

NXC-5032
## Current Behavior

Both pages label the Atomizer link with the product name alone. The Jest intro links test splitting to the unit and e2e section rather than the option that turns it on.

## Expected Behavior

The link reads task splitting (Atomizer), and both intros point at the plugin options section where `ciTargetName` lives.

## Related Issue(s)

NXC-5032
## Current Behavior

The migration entries target 23.3.0-beta.6, which is now published, so `nx migrate` skips them for anyone already on beta.6 or later.

## Expected Behavior

They target 23.3.0-beta.8, one above the latest published beta.

## Related Issue(s)

NXC-5032
@jaysoo
jaysoo merged commit 0440632 into master Sep 29, 2026
25 checks passed
@jaysoo
jaysoo deleted the NXC-5032 branch September 29, 2026 15:06
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants