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

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Chores
    • Updated Vite to v6.4.1 across examples, integrations, and toolings; bumped several dev tooling and type packages for compatibility.
  • Tests
    • Improved mocks, assertions, timers, dynamic-import handling, and added mock cleanup (clearAllMocks) for more reliable, deterministic test suites.
  • Configuration
    • Switched React JSX compiler option to "react-jsx" and added Next.js route type imports to improve type checking.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Nov 11, 2025

⚠️ No Changeset found

Latest commit: 9966a6f

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

Walkthrough

Project-wide dependency bumps (notably Vite), React example tsconfig JSX runtime changes, added Next.js route type imports in Next examples, and multiple test/mocks refinements (mock typing, factory helpers, clearer mock resets, and tightened assertions). No production API changes.

Changes

Cohort / File(s) Summary
Vite devDependency bumps
examples/.../*/package.json, integrations/*-vite/package.json, packages/vue-query-devtools/package.json, integrations/...
Updated devDependency vite from ^6.3.6^6.4.1 across many example and integration package.json files.
Root dependency & overrides
package.json
Updated root devDeps (vite, vitest, @vitest/coverage-istanbul, @vitest/eslint-plugin) and pnpm overrides (types, vite, esbuild).
Next.js ambient types
examples/react/*/next-env.d.ts
Added import "./.next/types/routes.d.ts" to several Next.js ambient type files to include route types.
React JSX runtime changes
examples/react/*/tsconfig.json
Changed compilerOptions.jsx from "preserve""react-jsx" in multiple React example tsconfigs; one tsconfig also extended includes with .next/dev/types/**/*.ts.
ESLint / Vitest / Vite config tweaks
eslint.config.js, packages/query-codemods/vite.config.ts, packages/solid-query-devtools/vite.config.ts
Merged vitest rules with explicit vitest/no-standalone-expect option; expanded vitest coverage include patterns; swapped defineConfig import to vitest/config.
Mocks & test setup refinements
packages/vue-query/src/__mocks__/*, packages/vue-query/src/__tests__/*, packages/angular-query-experimental/src/__tests__/*, packages/*/__tests__/*
Adjusted mock typings/exports (removed explicit Mock types, removed unrefQueryArgs), replaced inline mock factories with named helpers, added vi.clearAllMocks() in many beforeEach hooks, replaced restoreAllMocks() with clearAllMocks() in places.
Test assertions, timers & sequencing
packages/query-core/..., packages/query-persist-client-core/..., packages/react-query/..., packages/vue-query/src/__tests__/*, packages/solid-query/src/__tests__/*
Tightened or changed assertions (e.g., rejects.toBeInstanceOf, toHaveBeenCalledExactlyOnceWith, expect.objectContaining), updated fake timers usage, and added waits for dynamic imports/settling in tests.
Small typing / local changes
packages/vue-query-devtools/src/devtoolsPanel.vue, packages/query-core/src/__tests__/timeoutManager.test.tsx
Minor type annotation relaxations and mock typing adjustments in a few files.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

dependencies

Suggested reviewers

  • TkDodo
  • manudeli
  • ArturKustyaev

Poem

🐰 I nudged a version, hopped tests in line,

JSX now dances, imports look fine.
Mocks cleared, awaits in place, CI hums near,
A carrot for builds — hoppity cheer!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Upgrade to Vitest v4' directly and clearly summarizes the main change in the changeset, which involves upgrading the testing framework across multiple packages and examples to Vitest v4.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome. can you please fix the conflicts and I’ll try to ship it


expect(queryFn).toHaveBeenCalledOnce()
expect(queryFn).toHaveBeenCalledWith(context)
expect(queryFn).toHaveBeenCalledExactlyOnceWith(context)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh this is a nice new matcher 👍


afterEach(() => {
vi.useRealTimers()
Fallback.mockClear()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what’s that doing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left over from debugging why the test broke on the upgrade. Forgot to remove sorry

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@AlexanderKaran
Copy link
Author

@TkDodo sorry missed these comments will get this fixed tomorrow/day after

@AlexanderKaran
Copy link
Author

@TkDodo Fixed merge conflicts but now one test is failing, need to double check why

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (9)
examples/react/optimistic-updates-ui/next-env.d.ts (1)

3-3: Same concern as previous next-env.d.ts files.

This file has the same manual edit concern raised for examples/react/infinite-query-with-max-pages/next-env.d.ts. Please verify these imports are auto-generated by Next.js tooling.

examples/react/optimistic-updates-cache/tsconfig.json (1)

9-9: Same JSX runtime concern as other tsconfig files.

This JSX runtime change from "preserve" to "react-jsx" has the same compatibility implications flagged in examples/react/prefetching/tsconfig.json. Please verify this is intentional and tested across all affected examples.

examples/react/optimistic-updates-ui/tsconfig.json (1)

9-9: Same JSX runtime concern as other tsconfig files.

Duplicate of the JSX runtime compatibility concern raised in previous tsconfig.json files.

examples/react/nextjs-suspense-streaming/tsconfig.json (1)

19-19: Same JSX runtime concern as other tsconfig files.

This is the same JSX runtime change flagged in multiple other tsconfig.json files. Verify compatibility and intentionality.

examples/react/auto-refetching/next-env.d.ts (1)

3-3: Same concern as other next-env.d.ts files.

Duplicate of the auto-generated file editing concern raised for previous next-env.d.ts files.

examples/react/pagination/tsconfig.json (1)

18-18: Same JSX runtime concern as other tsconfig files.

This is the same JSX runtime compatibility concern raised across multiple tsconfig.json files in this PR.

examples/react/load-more-infinite-scroll/tsconfig.json (1)

18-18: Verify JSX runtime change is intentional.

Same concern as in examples/react/auto-refetching/tsconfig.json - the jsx option changed from "preserve" to "react-jsx". Please verify this is intentional and compatible with the React version used in this example.

examples/react/nextjs-app-prefetching/tsconfig.json (1)

19-19: Verify JSX runtime change is intentional.

Same JSX runtime change from "preserve" to "react-jsx" as in other examples. Please verify this is intentional and compatible.

examples/react/nextjs/tsconfig.json (1)

18-18: Verify JSX runtime change is intentional.

Same JSX runtime change from "preserve" to "react-jsx" as in other examples. Please confirm this is intentional and part of the Vitest v4 upgrade requirements.

🧹 Nitpick comments (6)
examples/solid/default-query-function/package.json (1)

17-17: Consider using exact version "6.4.1" if strict pinning is required.

The caret in ^6.4.1 allows minor and patch updates (6.4.x, 6.x where x ≥ 4) rather than pinning to the exact version. If the PR aims to pin the Vite version as mentioned in the description, use "vite": "6.4.1" instead. Vite 6.4.1 is secure with no known vulnerabilities.

examples/react/prefetching/tsconfig.json (1)

3-7: LGTM: Formatting improvements.

The multi-line formatting of the lib, include, and exclude arrays improves readability with no semantic changes.

Also applies to: 22-29

examples/react/optimistic-updates-cache/tsconfig.json (1)

5-8: LGTM: Formatting improvements.

The multi-line formatting of the configuration arrays improves readability without changing behavior.

Also applies to: 21-26

examples/react/optimistic-updates-ui/tsconfig.json (1)

5-8: LGTM: Formatting improvements.

Multi-line array formatting enhances readability with no semantic changes.

Also applies to: 21-26

examples/react/nextjs-suspense-streaming/tsconfig.json (1)

4-8: LGTM: Formatting improvements.

Multi-line formatting improves readability without semantic changes.

Also applies to: 34-36

examples/react/pagination/tsconfig.json (1)

3-7: LGTM: Formatting improvements.

The multi-line array formatting enhances readability with no semantic changes.

Also applies to: 22-29

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aeefc4c and ed0ad73.

📒 Files selected for processing (50)
  • eslint.config.js (1 hunks)
  • examples/react/algolia/package.json (1 hunks)
  • examples/react/auto-refetching/next-env.d.ts (1 hunks)
  • examples/react/auto-refetching/tsconfig.json (2 hunks)
  • examples/react/basic-graphql-request/package.json (1 hunks)
  • examples/react/basic/package.json (1 hunks)
  • examples/react/chat/package.json (1 hunks)
  • examples/react/default-query-function/package.json (1 hunks)
  • examples/react/devtools-panel/package.json (1 hunks)
  • examples/react/eslint-legacy/package.json (1 hunks)
  • examples/react/infinite-query-with-max-pages/next-env.d.ts (1 hunks)
  • examples/react/infinite-query-with-max-pages/tsconfig.json (2 hunks)
  • examples/react/load-more-infinite-scroll/next-env.d.ts (1 hunks)
  • examples/react/load-more-infinite-scroll/tsconfig.json (2 hunks)
  • examples/react/nextjs-app-prefetching/tsconfig.json (2 hunks)
  • examples/react/nextjs-suspense-streaming/tsconfig.json (3 hunks)
  • examples/react/nextjs/next-env.d.ts (1 hunks)
  • examples/react/nextjs/tsconfig.json (2 hunks)
  • examples/react/offline/package.json (1 hunks)
  • examples/react/optimistic-updates-cache/next-env.d.ts (1 hunks)
  • examples/react/optimistic-updates-cache/tsconfig.json (2 hunks)
  • examples/react/optimistic-updates-ui/next-env.d.ts (1 hunks)
  • examples/react/optimistic-updates-ui/tsconfig.json (2 hunks)
  • examples/react/pagination/next-env.d.ts (1 hunks)
  • examples/react/pagination/tsconfig.json (2 hunks)
  • examples/react/playground/package.json (1 hunks)
  • examples/react/prefetching/next-env.d.ts (1 hunks)
  • examples/react/prefetching/tsconfig.json (2 hunks)
  • examples/react/react-router/package.json (1 hunks)
  • examples/react/rick-morty/package.json (1 hunks)
  • examples/react/shadow-dom/package.json (1 hunks)
  • examples/react/simple/package.json (1 hunks)
  • examples/react/star-wars/package.json (1 hunks)
  • examples/react/suspense/package.json (1 hunks)
  • examples/solid/basic-graphql-request/package.json (1 hunks)
  • examples/solid/basic/package.json (1 hunks)
  • examples/solid/default-query-function/package.json (1 hunks)
  • examples/solid/simple/package.json (1 hunks)
  • examples/svelte/auto-refetching/package.json (1 hunks)
  • examples/svelte/basic/package.json (1 hunks)
  • examples/svelte/load-more-infinite-scroll/package.json (1 hunks)
  • examples/svelte/optimistic-updates/package.json (1 hunks)
  • examples/svelte/playground/package.json (1 hunks)
  • examples/svelte/simple/package.json (1 hunks)
  • examples/svelte/ssr/package.json (1 hunks)
  • examples/svelte/star-wars/package.json (1 hunks)
  • examples/vue/basic/package.json (1 hunks)
  • examples/vue/dependent-queries/package.json (1 hunks)
  • examples/vue/persister/package.json (1 hunks)
  • examples/vue/simple/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • examples/react/infinite-query-with-max-pages/tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (28)
  • examples/vue/dependent-queries/package.json
  • examples/svelte/load-more-infinite-scroll/package.json
  • examples/react/suspense/package.json
  • examples/react/chat/package.json
  • examples/svelte/auto-refetching/package.json
  • examples/solid/basic/package.json
  • examples/react/playground/package.json
  • examples/react/devtools-panel/package.json
  • examples/react/star-wars/package.json
  • examples/react/prefetching/next-env.d.ts
  • examples/svelte/optimistic-updates/package.json
  • examples/svelte/simple/package.json
  • examples/react/react-router/package.json
  • examples/react/basic/package.json
  • examples/react/load-more-infinite-scroll/next-env.d.ts
  • examples/solid/simple/package.json
  • examples/svelte/playground/package.json
  • examples/svelte/star-wars/package.json
  • examples/react/simple/package.json
  • examples/react/shadow-dom/package.json
  • examples/solid/basic-graphql-request/package.json
  • examples/react/pagination/next-env.d.ts
  • examples/react/basic-graphql-request/package.json
  • examples/svelte/basic/package.json
  • examples/vue/persister/package.json
  • examples/react/rick-morty/package.json
  • examples/react/optimistic-updates-cache/next-env.d.ts
  • examples/react/offline/package.json
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-19T03:18:18.303Z
Learnt from: oscartbeaumont
Repo: TanStack/query PR: 9564
File: packages/solid-query-devtools/src/production.tsx:2-3
Timestamp: 2025-08-19T03:18:18.303Z
Learning: In the solid-query-devtools package, the codebase uses a pattern of type-only default imports combined with typeof for component type annotations (e.g., `import type SolidQueryDevtoolsComp from './devtools'` followed by `typeof SolidQueryDevtoolsComp`). This pattern is consistently used across index.tsx and production.tsx files, and the maintainers prefer consistency over changing this approach.

Applied to files:

  • examples/solid/default-query-function/package.json
  • examples/react/load-more-infinite-scroll/tsconfig.json
  • examples/react/nextjs/next-env.d.ts
  • examples/react/optimistic-updates-ui/tsconfig.json
  • examples/react/optimistic-updates-cache/tsconfig.json
  • examples/react/infinite-query-with-max-pages/next-env.d.ts
  • examples/react/auto-refetching/next-env.d.ts
  • examples/react/optimistic-updates-ui/next-env.d.ts
  • examples/react/nextjs-app-prefetching/tsconfig.json
📚 Learning: 2025-09-02T17:57:33.184Z
Learnt from: TkDodo
Repo: TanStack/query PR: 9612
File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0
Timestamp: 2025-09-02T17:57:33.184Z
Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json.

Applied to files:

  • examples/solid/default-query-function/package.json
🔇 Additional comments (12)
examples/react/algolia/package.json (1)

23-23: Vite 6.4.1 is compatible with Vitest v4 and receives security patches.

Vitest v4 requires Vite >=v6.0.0, and Vite 6.4 receives important fixes and security patches. The version bump from 6.3.6 to 6.4.1 is appropriate and aligns with the PR's Vitest v4 upgrade objectives.

examples/react/eslint-legacy/package.json (1)

25-25: Version bump is appropriate and secure.

The upgrade from ^6.3.6 to ^6.4.1 is a straightforward patch-level bump within the actively maintained 6.x series. This version is fully compatible with Vitest v4 and has no known security vulnerabilities.

examples/react/default-query-function/package.json (1)

19-19: The vite 6.4.1 upgrade is valid and safe.

No direct vulnerabilities have been found for vite 6.4.1, it is compatible with Vitest 4.x (which lists vite ^6.0.0 as a compatible dependency), and the caret range aligns with standard monorepo override practices. The change appropriately supports the Vitest v4 upgrade objective.

examples/vue/basic/package.json (1)

18-18: Vite 6.4.1 is compatible with Vitest v4.

The patch version bump (6.3.6 → 6.4.1) aligns with Vitest v4's requirement for Vite >=v6.0.0. Vite 6.4.x is an actively supported version line receiving important fixes and security patches, making this a safe and intentional upgrade.

examples/vue/simple/package.json (1)

18-18: and

eslint.config.js (1)

53-61: LGTM! Configuration aligns with Vitest v4 upgrade best practices.

Spreading vitest.configs.recommended.rules ensures compatibility with the new plugin version, and the explicit override for vitest/no-standalone-expect to include testIf as a recognized test block function is necessary—testIf is actively used throughout test files as a conditional test wrapper.

examples/svelte/ssr/package.json (1)

21-21: Vite version bump to 6.4.1 is appropriate for Vitest v4 upgrade.

The upgrade to ^6.4.1 is compatible with Vitest 4.0.8 (the root version). Vite 6.x is officially supported by Vitest v4, and this minor bump aligns with the PR's upgrade objectives. Note that Vite 6 + Vitest 4 integration has some known issues around resolve.conditions, so running the full test suite locally (which you've already done) is the right verification approach.

examples/react/prefetching/tsconfig.json (1)

18-18: Verify JSX runtime change is compatible with React version and codebase.

Changing from "preserve" to "react-jsx" switches to React's automatic JSX runtime. Confirm:

  • React version is 17.0.0 or higher
  • Explicit import React statements in example files have been removed or are handled correctly
  • The connection to the Vitest v4 upgrade is clarified (no JSX runtime changes are mentioned in Vitest v4 migration guide)
examples/react/infinite-query-with-max-pages/next-env.d.ts (1)

3-3: Remove manual import from auto-generated file.

The import "./.next/types/routes.d.ts" should not be manually added to next-env.d.ts. This file is auto-generated by Next.js and any manual edits will be overwritten on the next build or dev command. Instead, ensure .next/types/**/*.ts is included in your project's tsconfig.json include array, which is the correct way Next.js provides typed route information.

examples/react/nextjs-app-prefetching/tsconfig.json (1)

38-38: LGTM: Standard Next.js type inclusion.

The addition of ".next/dev/types/**/*.ts" is a standard Next.js TypeScript configuration for including generated type definitions during development.

examples/react/nextjs/next-env.d.ts (1)

3-3: LGTM: Standard Next.js route type import.

The import of ./.next/types/routes.d.ts is part of Next.js's typed routing feature, providing type safety for routes. This is a standard pattern for Next.js projects with TypeScript.

examples/react/auto-refetching/tsconfig.json (1)

18-18: Verify JSX runtime change is intentional and compatible.

The jsx option changed from "preserve" to "react-jsx", which enables the new JSX transform introduced in React 17. While this is generally a positive modernization, it's unclear if this change is related to the Vitest v4 upgrade or was an unintended side-effect.

Please confirm:

  1. This change is intentional
  2. The example uses React 17 or later
  3. This doesn't break the example's functionality
#!/bin/bash
# Description: Check React version in this example and verify it supports react-jsx transform

# Find package.json and check React version
fd -t f "^package.json$" examples/react/auto-refetching --exec cat {} \; | jq -r '.dependencies.react // .devDependencies.react // "not found"'

@AlexanderKaran
Copy link
Author

@TkDodo Sorry it took me a while went on holiday. Fixed up all the Knip, ESLint and other issues caused by the conflict with main.

Let me know if I need to do any more work to it.

@nx-cloud
Copy link

nx-cloud bot commented Dec 27, 2025

View your CI Pipeline Execution ↗ for commit 9966a6f

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 4m 11s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 18s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-18 12:46:56 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
examples/react/infinite-query-with-max-pages/next-env.d.ts (1)

3-3: Same concern as in examples/react/prefetching/next-env.d.ts.

This file has the identical change (importing ./.next/types/routes.d.ts) and raises the same questions about committing auto-generated Next.js build artifacts. Please refer to the review comment on the prefetching example for details.

🧹 Nitpick comments (1)
packages/vue-query/src/__tests__/queryClient.test.ts (1)

347-352: Consider applying the same pattern to prefetchInfiniteQuery test.

The fetchInfiniteQuery tests now use expect.objectContaining to accommodate additional fields, but the prefetchInfiniteQuery test at lines 384-388 still uses an exact match assertion. If Vitest v4's internal changes affect both methods similarly, this inconsistency may cause the prefetchInfiniteQuery test to fail.

🔎 Suggested change for consistency
-      expect(QueryClientOrigin.prototype.prefetchInfiniteQuery).toBeCalledWith({
-        initialPageParam: 0,
-        queryKey: queryKeyUnref,
-        queryFn: fn,
-      })
+      expect(QueryClientOrigin.prototype.prefetchInfiniteQuery).toBeCalledWith(
+        expect.objectContaining({
+          initialPageParam: 0,
+          queryKey: queryKeyUnref,
+          queryFn: fn,
+        }),
+      )
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed0ad73 and b748a95.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • examples/react/auto-refetching/next-env.d.ts
  • examples/react/auto-refetching/tsconfig.json
  • examples/react/infinite-query-with-max-pages/next-env.d.ts
  • examples/react/infinite-query-with-max-pages/tsconfig.json
  • examples/react/load-more-infinite-scroll/next-env.d.ts
  • examples/react/load-more-infinite-scroll/tsconfig.json
  • examples/react/nextjs-app-prefetching/tsconfig.json
  • examples/react/nextjs-suspense-streaming/tsconfig.json
  • examples/react/nextjs/next-env.d.ts
  • examples/react/nextjs/tsconfig.json
  • examples/react/optimistic-updates-cache/next-env.d.ts
  • examples/react/optimistic-updates-cache/tsconfig.json
  • examples/react/optimistic-updates-ui/next-env.d.ts
  • examples/react/optimistic-updates-ui/tsconfig.json
  • examples/react/pagination/next-env.d.ts
  • examples/react/pagination/tsconfig.json
  • examples/react/prefetching/next-env.d.ts
  • examples/react/prefetching/tsconfig.json
  • packages/react-query/src/__tests__/useQuery.promise.test.tsx
  • packages/vue-query/src/__tests__/queryClient.test.ts
🚧 Files skipped from review as they are similar to previous changes (12)
  • examples/react/nextjs/next-env.d.ts
  • examples/react/pagination/next-env.d.ts
  • examples/react/auto-refetching/next-env.d.ts
  • examples/react/auto-refetching/tsconfig.json
  • examples/react/optimistic-updates-cache/tsconfig.json
  • examples/react/optimistic-updates-cache/next-env.d.ts
  • examples/react/pagination/tsconfig.json
  • examples/react/infinite-query-with-max-pages/tsconfig.json
  • examples/react/load-more-infinite-scroll/next-env.d.ts
  • examples/react/nextjs-app-prefetching/tsconfig.json
  • examples/react/optimistic-updates-ui/next-env.d.ts
  • packages/react-query/src/tests/useQuery.promise.test.tsx
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-08-19T03:18:18.303Z
Learnt from: oscartbeaumont
Repo: TanStack/query PR: 9564
File: packages/solid-query-devtools/src/production.tsx:2-3
Timestamp: 2025-08-19T03:18:18.303Z
Learning: In the solid-query-devtools package, the codebase uses a pattern of type-only default imports combined with typeof for component type annotations (e.g., `import type SolidQueryDevtoolsComp from './devtools'` followed by `typeof SolidQueryDevtoolsComp`). This pattern is consistently used across index.tsx and production.tsx files, and the maintainers prefer consistency over changing this approach.

Applied to files:

  • examples/react/infinite-query-with-max-pages/next-env.d.ts
  • examples/react/optimistic-updates-ui/tsconfig.json
  • examples/react/prefetching/tsconfig.json
  • examples/react/load-more-infinite-scroll/tsconfig.json
  • examples/react/prefetching/next-env.d.ts
  • examples/react/nextjs/tsconfig.json
📚 Learning: 2025-11-22T09:06:05.219Z
Learnt from: sukvvon
Repo: TanStack/query PR: 9892
File: packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx:331-335
Timestamp: 2025-11-22T09:06:05.219Z
Learning: In TanStack/query test files, when a queryFn contains side effects (e.g., setting flags for test verification), prefer async/await syntax for clarity; when there are no side effects, prefer the .then() pattern for conciseness.

Applied to files:

  • packages/vue-query/src/__tests__/queryClient.test.ts
📚 Learning: 2025-09-02T17:57:33.184Z
Learnt from: TkDodo
Repo: TanStack/query PR: 9612
File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0
Timestamp: 2025-09-02T17:57:33.184Z
Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json.

Applied to files:

  • packages/vue-query/src/__tests__/queryClient.test.ts
📚 Learning: 2025-11-02T22:52:33.071Z
Learnt from: DogPawHat
Repo: TanStack/query PR: 9835
File: packages/query-core/src/__tests__/queryClient.test-d.tsx:242-256
Timestamp: 2025-11-02T22:52:33.071Z
Learning: In the TanStack Query codebase, the new `query` and `infiniteQuery` methods support the `select` option for data transformation, while the legacy `fetchQuery` and `fetchInfiniteQuery` methods do not support `select` and should reject it at the type level.

Applied to files:

  • packages/vue-query/src/__tests__/queryClient.test.ts
🔇 Additional comments (9)
examples/react/load-more-infinite-scroll/tsconfig.json (1)

14-14: Verify this JSX runtime change is intentional.

This change switches from "preserve" to "react-jsx", enabling React 17+'s automatic JSX transform. While this is a valid modernization, it appears unrelated to the Vitest v4 upgrade scope of this PR.

For Next.js projects, "jsx": "preserve" is typically recommended because Next.js handles JSX transformation internally. However, "react-jsx" also works.

Please confirm:

  1. This change is intentional (not a side effect of tooling updates)
  2. The React version in this example is 17+ (required for the automatic JSX runtime)
  3. This aligns with the project's desired configuration
packages/vue-query/src/__tests__/queryClient.test.ts (3)

7-29: Well-designed dynamic mock pattern.

This approach dynamically spies on all QueryClient prototype methods, making the test setup more maintainable and automatically covering new methods added to the class. The pattern of using vi.importActual combined with vi.spyOn on prototype methods is idiomatic for Vitest.


37-40: Good addition of vi.clearAllMocks().

Since spies are attached to the prototype and shared across test instances, clearing mocks before each test is essential to prevent call history from leaking between tests.


365-370: Consistent with the updated assertion pattern.

examples/react/prefetching/tsconfig.json (1)

14-14: JSX runtime update looks good; verify this change is intentional.

The switch from "preserve" to "react-jsx" enables the modern React 17+ automatic JSX transform, which is fully supported by React 19 and eliminates the need for explicit React imports in JSX files. This is technically correct and aligns with current best practices.

However, since this PR focuses on upgrading to Vitest v4, please confirm this JSX configuration change is intentional (either related to the Vitest upgrade or a deliberate configuration cleanup), as opposed to an accidental side effect.

examples/react/optimistic-updates-ui/tsconfig.json (1)

6-6: JSX runtime update looks good; verify this change is intentional.

The switch to "react-jsx" enables the React 17+ automatic JSX transform. This is technically correct and aligns with modern React practices.

However, please confirm this configuration change is intentional and related to the Vitest v4 upgrade scope, as the connection is not immediately clear from the PR objectives.

examples/react/nextjs-suspense-streaming/tsconfig.json (1)

15-15: JSX runtime update looks good; verify this change is intentional.

The switch to "react-jsx" adopts the modern React automatic JSX transform, which is a best practice for React 17+ projects.

Please confirm this change is intentional within the scope of the Vitest v4 upgrade, as it appears to be part of a broader configuration update across multiple React examples.

examples/react/nextjs/tsconfig.json (1)

14-14: JSX runtime update looks good; verify this change is intentional.

The switch to "react-jsx" is well-supported by React 19.2.1 and represents a modern best practice by enabling the automatic JSX transform.

This change appears consistently across multiple React example tsconfigs in this PR. Please confirm this is intentional and either related to the Vitest v4 upgrade requirements or a deliberate configuration modernization effort.

examples/react/prefetching/next-env.d.ts (1)

3-3: Confirm whether this import pattern is required for the Vitest v4 upgrade or if it's a separate Next.js configuration update.

The import of ./.next/types/routes.d.ts in line 3 follows standard Next.js TypeScript configuration. The .next directory is properly ignored in .gitignore, and the referenced type definition file will be auto-generated locally when developers run next dev or next build. This pattern appears consistently across 8 example projects (prefetching, pagination, nextjs, load-more-infinite-scroll, optimistic-updates-cache, optimistic-updates-ui, auto-refetching, and infinite-query-with-max-pages), suggesting it's an intentional configuration rather than an error.

However, verify that this change is intentional for the upgrade objective and not an unrelated configuration update to the example projects.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 27, 2025

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9862

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9862

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9862

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9862

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@9862

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@9862

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9862

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9862

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@9862

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@9862

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9862

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9862

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@9862

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9862

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9862

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@9862

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9862

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9862

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@9862

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9862

commit: 9966a6f

@AlexanderKaran
Copy link
Author

@TkDodo Do you want to try and re-do this? Happy to re-work it.

@TkDodo
Copy link
Collaborator

TkDodo commented Jan 16, 2026

@AlexanderKaran trying to fix the pipeline ...

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@package.json`:
- Around line 89-93: The pnpm override forcing vite ^6.4.1 conflicts with the
Vue 2 example packages (examples/vue/2.7-basic and examples/vue/2.6-basic) which
require vite ^4.5.14 for vite-plugin-vue2@2.0.3; fix by updating package.json
pnpm.overrides to either (a) add package-specific overrides that pin vite to
^4.5.14 for those two example packages, or (b) exclude those example packages
from the global vite override, or (c) update the example projects to be
compatible with vite ^6.x and replace vite-plugin-vue2 with a compatible plugin;
locate and change the pnpm.overrides entry in package.json and the vite entries
in examples/vue/2.7-basic and examples/vue/2.6-basic to implement one of these
fixes.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71dfd88 and f013619.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json
🔇 Additional comments (1)
package.json (1)

56-57: All Vitest v4/Vite v6 versions are compatible and properly aligned.

vitest 4.0.17 supports Vite 5 and 6 (range: ^5.0.0 || ^6.0.0), and the included plugins (@vitest/coverage-istanbul 4.0.6, @vitest/eslint-plugin 1.4.0) are part of the Vitest 4.x ecosystem. The pnpm overrides for vite, esbuild, and @types packages are standard workspace management without conflicts.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@TkDodo
Copy link
Collaborator

TkDodo commented Jan 16, 2026

the remaining errors are legit I think, can you take another look please?

@AlexanderKaran
Copy link
Author

@TkDodo Digging into it now

- Fallback UI is not reset between tests -> moved to create a function for each
- ruleTests needs to be top level
@AlexanderKaran
Copy link
Author

@TkDodo Did some tweaks and running test locally is now passing

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@examples/react/simple/package.json`:
- Around line 17-19: Update the `@vitejs/plugin-react` dependency in package.json
from "@vitejs/plugin-react": "^4.3.4" to a v5+ range (for example "^5.0.0" or
"^5.x") so it is compatible with Vite 6.4.1; locate the dependency entry for
"@vitejs/plugin-react" and bump the version string, then run install and verify
the dev server/tests (Vite and Vitest) start correctly.

In `@examples/svelte/ssr/package.json`:
- Line 21: Update the vite dependency in package.json to pin it to Vite 5 for
SvelteKit 2.42 compatibility: replace the current "vite": "^6.4.1" entry with a
Vite 5.x range (e.g. "vite": "^5.x") so the project uses a supported peer
version; ensure package.json's "vite" key is updated and run an install to lock
the new version.

Comment on lines 17 to +19
"@vitejs/plugin-react": "^4.3.4",
"typescript": "5.8.3",
"vite": "^6.3.6"
"vite": "^6.4.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n examples/react/simple/package.json

Repository: TanStack/query

Length of output: 172


🌐 Web query:

Vite 6.4.1 release notes breaking changes

💡 Result:

Short answer: Vite 6.4.1 is a patch release with bug fixes — there are no listed breaking changes for v6.4.1. Notable fixes include preview: use host URL to open browser, HMR handler sequencing, addWatchFile/base fix, and a pluginFilter refactor. [1][2]

Sources:

  • Release/PR summary listing v6.4.1 commits and fixes. [1]
  • Vite v6 migration / changelog guidance noting Vite 6 aims to avoid breaking changes; breaking changes are tracked on the Breaking Changes page. [2]

🌐 Web query:

@vitejs/plugin-react 4.3.4 Vite 6 compatibility

💡 Result:

Short answer: 4.3.4 is not the recommended release for Vite 6 — upgrade to @vitejs/plugin-react v5+ for full Vite 6 / rolldown + Oxc support.

Why: @vitejs/plugin-react v4.3.4 was released in Nov 2024 and predates Vite 6. Vite 6 introduces the rolldown/Oxc architecture, and the plugin’s v5+ line incorporates Oxc-based React refresh and related changes to target that new runtime; using v4.x may work via the compatibility layer but isn’t the intended/optimal combination. Recommend upgrading to @vitejs/plugin-react v5+ when moving to Vite 6. [1][2][3]

Sources:

  • @vitejs/plugin-react releases (4.3.4 date). [1]
  • Vite 6 announcement. [2]
  • Rolldown / Oxc notes: @vitejs/plugin-react v5.0.0+ uses Oxc (migration/compatibility details). [3]

🌐 Web query:

Vitest v4 Vite version requirements

💡 Result:

Short answer: Vitest v4 expects Vite 6+ (official compatibility targets Vite 6 and Vite 7). Some @vitest packages also list broader peer ranges in practice (e.g. ^5 || ^6 || ^7), but the documented Vitest v4 package targets Vite 6/7. [1][2]

Sources:

  • Vitest migration / docs (v4 changes & Module Runner — Vitest v4 documentation). [1]
  • Example package metadata showing Vite peer ranges used by @vitest packages (peer: ^5.0.0 || ^6.0.0 || ^7.0.0-0). [2]

Upgrade @vitejs/plugin-react to v5+ for Vite 6.4.1 compatibility.
@vitejs/plugin-react v4.3.4 predates Vite 6 and is not the recommended version for this stack. Vite 6 introduces rolldown/Oxc architecture, and @vitejs/plugin-react v5+ incorporates the necessary Oxc-based changes to pair with it. While v4.3.4 may work via a compatibility layer, upgrade to v5+ for optimal support. Vitest v4 is compatible with Vite 6.

🤖 Prompt for AI Agents
In `@examples/react/simple/package.json` around lines 17 - 19, Update the
`@vitejs/plugin-react` dependency in package.json from "@vitejs/plugin-react":
"^4.3.4" to a v5+ range (for example "^5.0.0" or "^5.x") so it is compatible
with Vite 6.4.1; locate the dependency entry for "@vitejs/plugin-react" and bump
the version string, then run install and verify the dev server/tests (Vite and
Vitest) start correctly.

"svelte-check": "^4.3.1",
"typescript": "5.8.3",
"vite": "^6.3.6"
"vite": "^6.4.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Vite 6.4.1 release notes breaking changes

💡 Result:

There are no breaking changes listed for Vite v6.4.1. See the Vite Releases/Changes and the package changelog. [1][2]

Sources:
[1] Vite Releases / supported versions and changelog guidance.
[2] Vite package CHANGELOG (v6.x entries).


🌐 Web query:

Vite 6.4 SvelteKit 2.42 compatibility

💡 Result:

Short answer: Not officially—SvelteKit 2.x (including 2.42) requires/targets Vite 5 as the minimum supported Vite, while Vite 6 is a new major release that framework/plugin authors must opt in to. Vite 6 aims for backward compatibility, but SvelteKit (and @sveltejs/vite-plugin-svelte) must publish compatible peer-deps before you can rely on Vite 6.4 without issues. [1][2]

What to do:

  • For production/stability, stick with vite@5.x with SvelteKit 2.42 until the SvelteKit team (or @sveltejs/vite-plugin-svelte) updates peerDependencies to explicitly support Vite 6.
  • If you want to experiment, try Vite 6.4 in a branch and run your full test/build matrix; be prepared to pin versions or revert if you hit plugin/treeshaking/runtime problems. See Vite 6 release notes and SvelteKit migration requirements for details. [1][2]

Sources:

  • Vite 6 announcement / compat notes. [1]
  • SvelteKit “migrating to SvelteKit v2” / updated dependency requirements (vite@5 minimum). [2]

🌐 Web query:

@sveltejs/vite-plugin-svelte 5.1 Vite 6.4 compatibility

💡 Result:

Short answer: Yes — @sveltejs/vite-plugin-svelte v5.1 is compatible with Vite 6. V5 explicitly adds support for Vite 6, and v5.1 includes a minor that requires Vite >= 6.2 for a CSS scoping optimization (so Vite 6.4 is fine). [1][2][3]

Sources:

  • plugin releases (v5.x / v5.1.1). [1]
  • v5 changelog notes: "Support Vite 6" and v5.1.0 requires Vite 6.2+ for the scoped-css change. [2]
  • Vite 6 announcement / release notes. [3]

Revert Vite to 5.x for SvelteKit 2.42 compatibility.

SvelteKit 2.42 targets Vite 5.x and does not officially support Vite 6. While @sveltejs/vite-plugin-svelte@5.1.1 is compatible with Vite 6.4.1, the framework itself has not updated its peer-dependencies to opt in to Vite 6. For production stability, pin vite to ^5.x until SvelteKit publishes Vite 6 support. Alternatively, test thoroughly if proceeding with Vite 6.4.1.

🤖 Prompt for AI Agents
In `@examples/svelte/ssr/package.json` at line 21, Update the vite dependency in
package.json to pin it to Vite 5 for SvelteKit 2.42 compatibility: replace the
current "vite": "^6.4.1" entry with a Vite 5.x range (e.g. "vite": "^5.x") so
the project uses a supported peer version; ensure package.json's "vite" key is
updated and run an install to lock the new version.

@sentry
Copy link

sentry bot commented Jan 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.86%. Comparing base (0525ad1) to head (9966a6f).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #9862      +/-   ##
==========================================
- Coverage   46.05%   36.86%   -9.19%     
==========================================
  Files         200      245      +45     
  Lines        8542    11102    +2560     
  Branches     1976     2080     +104     
==========================================
+ Hits         3934     4093     +159     
- Misses       4150     6484    +2334     
- Partials      458      525      +67     
Components Coverage Δ
@tanstack/angular-query-experimental 46.35% <ø> (-47.51%) ⬇️
@tanstack/eslint-plugin-query 88.92% <ø> (+5.10%) ⬆️
@tanstack/query-async-storage-persister 43.85% <ø> (ø)
@tanstack/query-broadcast-client-experimental 24.39% <ø> (ø)
@tanstack/query-codemods 0.00% <ø> (ø)
@tanstack/query-core 75.54% <ø> (-22.34%) ⬇️
@tanstack/query-devtools 3.38% <ø> (ø)
@tanstack/query-persist-client-core 80.12% <ø> (+0.12%) ⬆️
@tanstack/query-sync-storage-persister 84.61% <ø> (ø)
@tanstack/query-test-utils 77.77% <ø> (ø)
@tanstack/react-query 29.00% <ø> (-67.74%) ⬇️
@tanstack/react-query-devtools 9.25% <ø> (ø)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (ø)
@tanstack/solid-query 53.52% <ø> (-24.29%) ⬇️
@tanstack/solid-query-devtools 64.17% <ø> (ø)
@tanstack/solid-query-persist-client 100.00% <ø> (ø)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query 35.67% <100.00%> (-36.25%) ⬇️
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants