chore(deps-dev): upgrade vitest to v5 - #1529
Merged
Merged
Conversation
Upgrade vitest and @vitest/coverage-v8 to 5.0.0, drop the now-unnecessary @vitest/expect dependency, update custom matcher types for the Matchers<R, T> interface, and ignore Vitest 5's .vitest artifact directory.
|
| Filename | Overview |
|---|---|
| package.json | Upgrades the Vitest development dependencies and removes the obsolete standalone assertion dependency. |
| package-lock.json | Resolves Vitest 5 and its updated transitive test-toolchain dependencies. |
| vitest.config.ts | Limits coverage collection to source files while preserving the generated GitHub Actions bundle exclusion. |
| test/helpers/vitest.matchers.ts | Migrates the custom matcher typing and result import to Vitest 5’s bundled assertion API. |
| test/helpers/git-mock.ts | Adds the Git-root mock and strengthens cleanup of timers and global prompt state. |
| test/lib/createGHA.test.ts | Adjusts fake-timer and prompt setup to remain deterministic under Vitest 5. |
Reviews (5): Last reviewed commit: "test: remove Temporal comment from GHA m..." | Re-trigger Greptile
Vitest 5 formats test.each titles with pretty-format and no longer quotes interpolated strings, so snapshot keys need updating. Give createGHA cases explicit names instead of concatenating cmd/label placeholders. Also pin coverage.include to src. Vitest 5's coverageConfigDefaults.exclude is empty and include/exclude matching is stricter, which otherwise reports dist and test helpers.
Vitest 5's setSystemTime also fakes Temporal when it is present, which is the case on Node 26 (CI's `latest`). Limit fake timers to Date, restore real timers after each test, mock git.revparse, and reset prompts.inject/override so GHA onboarding tests cannot leak prompt state across cases.
Oxlint flags the internal `_injected` field we clear between GHA tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upgrade the test runner from Vitest 4 to Vitest 5. Migration notes: https://vitest.dev/guide/migration/
Changes
vitestand@vitest/coverage-v8from^4.1.9to^5.0.0@vitest/expect— Vitest 5 bundles assertions intovitestitself, and the standalone package no longer shares state with Vitest'sexpecttoBeValidSchemamatcher to augmentMatchers<R, T>and importMatcherResultfromvitest.vitest/artifact directory in git, oxlint, and oxfmtcoverage.includetosrc— Vitest 5'scoverageConfigDefaults.excludeis empty and include/exclude matching is stricter, which otherwise reportsdist/and test helperscreateGHAcases now use an explicit$nameinstead of concatenating$cmd $labelDate,git.revparseis mocked, andprompts.inject/prompts.overrideare reset between testsCompatibility notes
Vitest 5 requires Node.js >= 22.12.0 (and Vite >= 6.4.0, pulled in transitively). That only affects running tests; the published CLI
enginesremain>=20.10.0.CI already exercises
lts/-1/lts/*/latest, which are all Node 22+.clearMocksnow defaults totrue. Our spies are set up inbeforeEach, so this should not change test behavior.Verification
npx vitest run --coveragelocally: 35 files passed, 606 tests passed (15 skipped, 11 todo). Coverage onsrc/is ~89% statements.