Skip to content

chore(deps-dev): upgrade vitest to v5 - #1529

Merged
erunion merged 5 commits into
nextfrom
erunion/vitest-5-7047
Sep 4, 2026
Merged

chore(deps-dev): upgrade vitest to v5#1529
erunion merged 5 commits into
nextfrom
erunion/vitest-5-7047

Conversation

@erunion

@erunion erunion commented Sep 4, 2026

Copy link
Copy Markdown
Member

Upgrade the test runner from Vitest 4 to Vitest 5. Migration notes: https://vitest.dev/guide/migration/

Changes

  • Bump vitest and @vitest/coverage-v8 from ^4.1.9 to ^5.0.0
  • Remove @vitest/expect — Vitest 5 bundles assertions into vitest itself, and the standalone package no longer shares state with Vitest's expect
  • Update our custom toBeValidSchema matcher to augment Matchers<R, T> and import MatcherResult from vitest
  • Ignore Vitest 5's new .vitest/ artifact directory in git, oxlint, and oxfmt
  • 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
  • Update snapshot keys for pretty-format title changes (interpolated strings are no longer quoted). createGHA cases now use an explicit $name instead of concatenating $cmd $label
  • Harden GHA test mocks: fake timers are limited to Date, git.revparse is mocked, and prompts.inject / prompts.override are reset between tests

Compatibility 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 engines remain >=20.10.0.

CI already exercises lts/-1 / lts/* / latest, which are all Node 22+.

clearMocks now defaults to true. Our spies are set up in beforeEach, so this should not change test behavior.

Verification

npx vitest run --coverage locally: 35 files passed, 606 tests passed (15 skipped, 11 todo). Coverage on src/ is ~89% statements.

Open in Web Open in Cursor 

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.
@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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.
@erunion erunion added enhancement New feature or request dependencies Pull requests that update a dependency file labels Sep 4, 2026
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.
@erunion
erunion marked this pull request as ready for review September 4, 2026 17:55
@erunion
erunion merged commit 8c7d0c4 into next Sep 4, 2026
11 checks passed
@erunion
erunion deleted the erunion/vitest-5-7047 branch September 4, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants