Complete jest -> vitest migration#4197
Open
trevor-scheer wants to merge 4 commits intographql:mainfrom
Open
Conversation
|
jest -> vitest migration
d740a1c to
c77cdd9
Compare
8c5870b to
f6f8cca
Compare
dimaMachina
reviewed
Apr 21, 2026
| "test:coverage": "yarn jest --coverage", | ||
| "test:watch": "yarn jest --watch", | ||
| "test": "turbo run test --filter='./packages/*'", | ||
| "test:ci": "yarn tsc && yarn test", |
Collaborator
There was a problem hiding this comment.
Suggested change
| "test:ci": "yarn tsc && yarn test", | |
| "test:ci": "yarn test", |
do we really need run this script before tests?
dimaMachina
approved these changes
Apr 21, 2026
Collaborator
dimaMachina
left a comment
There was a problem hiding this comment.
amazing improvement!
f6f8cca to
f647f1e
Compare
Use the dedicated vitest integration which properly extends `expect` and augments vitest types, rather than relying on the Jest compatibility shim. Drop `@testing-library/jest-dom` from tsconfig `types` arrays since the `/vitest` entrypoint handles type augmentation via its own `import 'vitest'` declaration.
5a3ee5c to
a41e83d
Compare
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.
Summary
Migrates the last Jest package to vitest and removes all Jest infrastructure from the monorepo. The mechanical
jest.*→vi.*port was straightforward, butfetch-mockcouldn't follow — vitest's mock system doesn't intercept CJSrequire()calls fromnode_modules, sojest.mock('@whatwg-node/fetch')silently stops working. Replacedfetch-mockwith MSW which intercepts at the network layer.Changes
jest.*tovi.*(imports, mocks, timers, type helpers)vitest.config.mtswithclearMocks,graphqldedup alias, andgraphql-language-servicesrc alias for unbundled workspace resolutionfetch-mockv6 withmswv2 for HTTP mocking inGraphQLCache.testandMessageProcessor.spec@whatwg-node/fetch,cross-envfrom server devDeps (only existed for the old mock setup)jest,ts-jest,@types/jest,@types/fetch-mock,fetch-mock,babel-plugin-macros,eslint-plugin-jestfrom rootjest.config.js,jest.config.base.js, trimbabel.config.jsenv.testblocktest→turbo run test,test:ci→yarn tsc && yarn testeslint-plugin-jestwitheslint-plugin-vitestfor test lint coverageNecessary changes due to removing Jest
@ts-expect-erroron prettier subpath importsSeveral files import prettier subpaths like
prettier/parser-graphql. WithmoduleResolution: "node", TypeScript can't resolve these because it doesn't read theexportsfield inpackage.json. Previously this worked because@types/prettier@2.6.4(a transitive dep ofjest-snapshot) provided the type declarations. With jest removed, those types are gone. The proper fix is migrating tomoduleResolution: "node16"or"bundler", but that's out of scope here.jsdomadded as an explicit dependencySix packages set
environment: 'jsdom'in their vitest configs. Vitest lists jsdom as an optional peer dep, so it must be installed explicitly. It was previously available as a transitive dependency of jest (jest-environment-jsdom→jsdom).Note
The
Jest Unit & Integration Testscheck will need to be marked as not required in order for this to pass once it's ready to merge.