Skip to content

Conversation

@AlexanderKaran
Copy link

@AlexanderKaran AlexanderKaran commented Nov 11, 2025

🎯 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

@changeset-bot
Copy link

changeset-bot bot commented Nov 11, 2025

⚠️ No Changeset found

Latest commit: aeefc4c

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

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; replaced toHaveBeenCalledOnce() with toHaveBeenCalledExactlyOnceWith()
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 sound
  • packages/react-query/src/__tests__/useQuery.promise.test.tsx — cancellation flow rewrite with waitFor and timer expansion should be verified against intended behavior
  • packages/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

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 PR description follows the required template with all sections completed: Changes, Checklist, and Release Impact are present and properly filled out.
✨ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant