Upgrade to Vitest v4
π― Changes
Upgrade TanStack Query to use Vitest 4. Most changes were around mocks, testing functions being used and some config tweaks.
A few gotchas I am unsure about:
- Had to pin Vite version in overrides
- Vitest 4 has some changes under the hood that causes a few tests to fail in react-query not 100% sure about the solution
Please let me know if I have messed with things that should not be touched.
β Checklist
- [x] I have followed the steps in the Contributing guide.
- [x] I have tested this code locally with
pnpm run test:pr.
π Release Impact
- [ ] This change affects published code, and I have generated a changeset.
- [x] This change is docs/CI/dev-only (no release).
Summary by CodeRabbit
- Chores
- Updated Vite from ^6.3.6 to ^6.4.1 across all example projects and integrations
- Updated root dependencies: @tanstack/config, @types/node, vitest, and related testing tools
- Enhanced TypeScript configuration for Next.js examples with improved route type support
- Improved test infrastructure with better mock handling and type annotations
β οΈ No Changeset found
Latest commit: aeefc4c8dbbe810ff9f5a70146e2a81ece108f11
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
Walkthrough
Large monorepo dependency and test infrastructure update. Vite bumped from ^6.3.6 to ^6.4.1 across ~40 example and integration package files. Root package.json updated with @tanstack/config, @types/node, @vitest/*, and vitest bumps. Next.js type references added to multiple next-env.d.ts files. Test mocks refactored for type safety; test setup standardized with clearAllMocks and improved spy patterns.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Vite devDependency bumps in React examples examples/react/algolia/package.json, examples/react/basic-graphql-request/package.json, examples/react/basic/package.json, examples/react/chat/package.json, examples/react/default-query-function/package.json, examples/react/devtools-panel/package.json, examples/react/eslint-legacy/package.json, examples/react/offline/package.json, examples/react/playground/package.json, examples/react/react-router/package.json, examples/react/rick-morty/package.json, examples/react/shadow-dom/package.json, examples/react/simple/package.json, examples/react/star-wars/package.json, examples/react/suspense/package.json |
Updated vite from ^6.3.6 to ^6.4.1 in devDependencies |
Vite devDependency bumps in Solid examples examples/solid/basic-graphql-request/package.json, examples/solid/basic/package.json, examples/solid/default-query-function/package.json, examples/solid/simple/package.json |
Updated vite from ^6.3.6 to ^6.4.1 in devDependencies |
Vite devDependency bumps in Svelte examples examples/svelte/auto-refetching/package.json, examples/svelte/basic/package.json, examples/svelte/load-more-infinite-scroll/package.json, examples/svelte/optimistic-updates/package.json, examples/svelte/playground/package.json, examples/svelte/simple/package.json, examples/svelte/ssr/package.json, examples/svelte/star-wars/package.json |
Updated vite from ^6.3.6 to ^6.4.1 in devDependencies |
Vite devDependency bumps in Vue examples examples/vue/basic/package.json, examples/vue/dependent-queries/package.json, examples/vue/persister/package.json, examples/vue/simple/package.json |
Updated vite from ^6.3.6 to ^6.4.1 in devDependencies |
Vite devDependency bumps in integrations integrations/react-vite/package.json, integrations/solid-vite/package.json, integrations/svelte-vite/package.json, integrations/vue-vite/package.json |
Updated vite from ^6.3.6 to ^6.4.1 in devDependencies |
Next.js route type references examples/react/auto-refetching/next-env.d.ts, examples/react/infinite-query-with-max-pages/next-env.d.ts, examples/react/load-more-infinite-scroll/next-env.d.ts, examples/react/nextjs-suspense-streaming/next-env.d.ts, examples/react/nextjs/next-env.d.ts, examples/react/optimistic-updates-cache/next-env.d.ts, examples/react/optimistic-updates-ui/next-env.d.ts, examples/react/pagination/next-env.d.ts, examples/react/prefetching/next-env.d.ts |
Added triple-slash reference directive to ./.next/types/routes.d.ts for Next.js route type resolution |
Root dependency updates package.json |
Bumped @tanstack/config (^0.20.2 β ^0.22.0), @types/node (^22.15.3 β ^24.10.0), @vitest/coverage-istanbul (3.2.4 β 4.0.6), @vitest/eslint-plugin (^1.1.36 β ^1.4.0), vite (^6.3.6 β ^6.4.1), vitest (3.2.4 β 4.0.8); updated pnpm overrides with vite and @types/node constraints |
Vue query mock type refactoring packages/vue-query/src/__mocks__/useBaseQuery.ts, packages/vue-query/src/__mocks__/useQueryClient.ts |
Removed explicit Mock<> type annotations; replaced vi.importActual typing approach with typed module alias; removed unrefQueryArgs export |
Vue query test infrastructure updates packages/vue-query/src/__tests__/queryClient.test.ts, packages/vue-query/src/__tests__/useQueries.test.ts, packages/vue-query/src/__tests__/useQueryClient.test.ts |
Added dynamic prototype spying on QueryClient; switched to vi.clearAllMocks() instead of restoreAllMocks(); broadened expect assertions with objectContaining; refactored vue-demi mocks with namespace import |
Angular query test mock setup packages/angular-query-experimental/src/__tests__/inject-devtools-panel.test.ts, packages/angular-query-experimental/src/__tests__/with-devtools.test.ts |
Extracted inline mock factories into named helper functions; added vi.clearAllMocks() in beforeEach; added vi.dynamicImportSettled() awaits in test flows |
Solid query mock implementation packages/solid-query/src/__tests__/useQueries.test.tsx |
Refactored QueriesObserver spy to accept (client, queries) parameters instead of single function argument |
React query test updates packages/react-query/src/__tests__/usePrefetchInfiniteQuery.test.tsx, packages/react-query/src/__tests__/useQuery.promise.test.tsx |
Added Fallback.mockClear() in afterEach; increased test timeout; expanded fake timer tracking; rewrote cancellation flow assertions with waitFor |
Test type annotation updates packages/query-core/src/__tests__/timeoutManager.test.tsx, packages/query-persist-client-core/src/__tests__/createPersister.test.ts |
Updated consoleErrorSpy type to MockInstance |
Vite config updates packages/query-codemods/vite.config.ts, packages/solid-query-devtools/vite.config.ts |
Expanded coverage include pattern from src/\\ to src/\\.{js,ts,cjs,mjs,jsx,tsx}; changed defineConfig import from vite to vitest/config |
Vue query devtools dependencies packages/vue-query-devtools/package.json |
Updated vite from ^6.3.6 to ^6.4.1 in devDependencies |
React query testing dependencies packages/react-query/package.json |
Bumped @testing-library/react-render-stream from ^2.0.0 to ^2.0.2 |
Estimated code review effort
π― 2 (Simple) | β±οΈ ~15 minutes
- Vite and dependency bumps (~30+ homogeneous package.json updates) are routine and carry minimal risk
- Next.js type reference additions are straightforward and non-breaking
- Mock type annotation cleanup in vue-query is a safe simplification that maintains functionality
- Test infrastructure changes (clearAllMocks vs. restoreAllMocks, mock helper extraction) are intentional patterns and low-risk
Areas requiring extra attention:
packages/vue-query/src/__tests__/queryClient.test.tsβ dynamic prototype spying on QueryClient and broadened assertions with expect.objectContaining warrant validation that expectations remain soundpackages/react-query/src/__tests__/useQuery.promise.test.tsxβ cancellation flow rewrite with waitFor and timer expansion should be verified against intended behaviorpackages/angular-query-experimental/src/__tests__/with-devtools.test.tsβ added vi.dynamicImportSettled() awaits across multiple tests; confirm async import handling is necessary and complete
Possibly related PRs
- TanStack/query#9671 β Overlapping Vite devDependency bumps across example package.json files
- TanStack/query#9636 β Related Vite version constraint updates in package.json files
- TanStack/query#9712 β Mass dependency bump churn affecting examples and integrations
Suggested labels
dependencies, package: react-query, package: solid-query-devtools, package: vue-query, package: query-core, test-infrastructure
Suggested reviewers
- TkDodo
- ArturKustyaev
Poem
π° A rabbit hops through package trees,
Vite bumps dance upon the breeze,
Mock types cleaned, tests aligned,
Dependencies refined.
Routes typed, timers awaitβ
All updates, truly great! π₯
Pre-merge checks and finishing touches
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
β Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | β Passed | The title 'Upgrade to Vitest v4' clearly and concisely summarizes the main change: upgrading the testing framework from Vitest v3 to v4, which aligns with the primary objective evident in the changeset. |
| Description check | β Passed | The pull request description follows the required template with all sections completed, including changes description, checklist items marked, and release impact clarified. |
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
@TkDodo sorry missed these comments will get this fixed tomorrow/day after
@TkDodo Fixed merge conflicts but now one test is failing, need to double check why