Skip to content

Bump Vitest to v4 to unblock @storybook/addon-vitest#4260

Merged
trevor-scheer merged 6 commits into
graphql:mainfrom
trevor-scheer:trevor/vitest-v4
May 14, 2026
Merged

Bump Vitest to v4 to unblock @storybook/addon-vitest#4260
trevor-scheer merged 6 commits into
graphql:mainfrom
trevor-scheer:trevor/vitest-v4

Conversation

@trevor-scheer
Copy link
Copy Markdown
Contributor

Background

#4257 is adding a Storybook a11y CI gate to @graphiql/react, currently via @storybook/test-runner + axe-playwright. The paved path Storybook recommends is @storybook/addon-vitest, which folds stories into the existing Vitest suite and avoids a separate workflow file, test-runner config, and JSON baseline. That addon requires Vitest ≥ 3; we're on ^2.1.9 workspace-wide, so this upgrade is a prerequisite for taking the cleaner approach in #4257 rather than landing cruft we'd immediately want to rip out.

What this enables

Switching #4257 to:

  • @storybook/addon-vitest + @storybook/addon-a11y
  • Browser-mode Vitest project for stories (Playwright Chromium, like the test-runner uses today)
  • Per-story parameters.a11y.test: 'error' | 'todo' | 'off' — no JSON baseline file
  • No new workflow, no .storybook/test-runner.ts, no a11y-baseline.json, no @storybook/test-runner / axe-playwright devDeps

Changes

Workspace-wide bump to Vitest v4 and its companion peer-deps. A few mocks needed light fixups for v4's stricter new semantics.

- `vitest` `^2.1.9` -> `^4.1.6`
- `@vitest/web-worker` `3.1.4` -> `^4.1.6`
- `vitest-canvas-mock` `0.3.3` -> `^1.1.4`
- `__mocks__/zustand` now uses `vi.importActual`; renamed to `.mts` for top-level `await` under `nodenext`. v4 redirected the static `import ... from 'zustand'` back into the mock, causing infinite recursion.
- `__mocks__/monaco-editor`'s `ResizeObserver` and the `Logger` factories in `graphql-language-service-server` tests switched to real classes — v4 forbids calling `vi.fn().mockReturnValue()` / `.mockImplementation()` with `new`.
- `GraphiQL.spec.tsx` "does not allow ... persisting headers" caps `findByText` at 1s. v2 won the race against the 9s `testTimeout`; v4 doesn't.
- `graphql-language-service-server/vitest.config.mts`: replaced removed `poolOptions.threads.singleThread` with top-level `fileParallelism: false`.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

⚠️ No Changeset found

Latest commit: ddc637c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

These explained "v4 changed X" rather than describing current behavior.
@trevor-scheer trevor-scheer requested a review from dimaMachina May 14, 2026 06:25
@trevor-scheer trevor-scheer marked this pull request as ready for review May 14, 2026 13:34
@trevor-scheer trevor-scheer merged commit 471da20 into graphql:main May 14, 2026
13 checks passed
@trevor-scheer trevor-scheer deleted the trevor/vitest-v4 branch May 14, 2026 15:30
trevor-scheer added a commit that referenced this pull request May 14, 2026
## Summary

Times out at the default 9s on every CI run since Vitest 4 landed
(#4260). It's the only test in `GraphiQL.spec.tsx` that boots Monaco's
`editorWorkerService` from a cold start; the rest get a warm worker.
Vitest 4's pool switch from `threads` to `forks` pushed cold-boot just
past 9s.

Bumped to 20s on this one test, with an inline comment explaining why
for the next person.

Failed on two back-to-back runs of an unrelated PR:
-
https://github.com/graphql/graphiql/actions/runs/25878177678/job/76051305013
-
https://github.com/graphql/graphiql/actions/runs/25878177678/job/76052552437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant