Skip to content

test({react,preact}-query/useInfiniteQuery): assert 'queryFn' call count in skipToken test - #11433

Merged
sukvvon merged 1 commit into
mainfrom
test/react-preact-useinfinitequery-skiptoken-call-count
Sep 6, 2026
Merged

test({react,preact}-query/useInfiniteQuery): assert 'queryFn' call count in skipToken test#11433
sukvvon merged 1 commit into
mainfrom
test/react-preact-useinfinitequery-skiptoken-call-count

Conversation

@sukvvon

@sukvvon sukvvon commented Sep 6, 2026

Copy link
Copy Markdown
Member

🎯 Changes

CodeRabbit flagged the same gap on #11423 (solid-query): should not fetch when queryFn is skipToken, and fetch once it is replaced only asserted the final rendered data, so multiple fetches after postId is set would still pass.

Wraps queryFn in vi.fn and asserts it is not called before postId is set, and called exactly once after, in both react-query's and preact-query's useInfiniteQuery.test.tsx.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 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

  • Tests
    • Improved coverage for infinite-query behavior when execution is skipped.
    • Verified that the query function is not called while skipping is active and runs exactly once when enabled.

@sukvvon sukvvon self-assigned this Sep 6, 2026
@nx-cloud

nx-cloud Bot commented Sep 6, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 806caf3

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

☁️ Nx Cloud last updated this comment at 2026-09-06 14:22:20 UTC

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: cba63ddb-40ae-451b-83db-87c04138fdb0

📥 Commits

Reviewing files that changed from the base of the PR and between 14ba7be and 806caf3.

📒 Files selected for processing (2)
  • packages/preact-query/src/__tests__/useInfiniteQuery.test.tsx
  • packages/react-query/src/__tests__/useInfiniteQuery.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The React and Preact infinite query tests now use shared mocked query functions. They verify that skipToken prevents calls and that setting postId triggers exactly one query.

Changes

skipToken test coverage

Layer / File(s) Summary
Query function call coverage
packages/preact-query/src/__tests__/useInfiniteQuery.test.tsx, packages/react-query/src/__tests__/useInfiniteQuery.test.tsx
The tests use shared vi.fn query functions, select skipToken until postId is set, and assert zero initial calls followed by one query call.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 806ca

This updates infinite-query tests to verify that skipToken prevents query execution until postId is set, then triggers one fetch. No production behavior is changed, and no current merge-blocking risk remains.

Suggested reviewers: tkdodo

🚥 Pre-merge checks | ✅ 4 | ❌ 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the React and Preact query tests and the added queryFn call-count assertions.
Description check ✅ Passed The description explains the motivation and changes, completes all required template sections, and identifies the change as dev-only with no release impact.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/react-preact-useinfinitequery-skiptoken-call-count

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.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

2 package(s) bumped directly, 23 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/svelte-query 6.1.48 → 6.2.0 Changeset
@tanstack/svelte-query-devtools 6.1.48 → 6.2.0 Dependent
@tanstack/svelte-query-persist-client 6.1.48 → 6.2.0 Dependent
@tanstack/vue-query-devtools 6.1.48 → 6.2.0 Dependent

🟩 Patch bumps

Package Version Reason
@tanstack/query-core 5.102.8 → 5.102.9 Changeset
@tanstack/angular-query-experimental 5.102.8 → 5.102.9 Dependent
@tanstack/angular-query-persist-client 5.102.8 → 5.102.9 Dependent
@tanstack/eslint-plugin-query 5.102.8 → 5.102.9 Dependent
@tanstack/lit-query 0.2.20 → 0.2.21 Dependent
@tanstack/preact-query 5.102.8 → 5.102.9 Dependent
@tanstack/preact-query-devtools 5.102.8 → 5.102.9 Dependent
@tanstack/preact-query-persist-client 5.102.8 → 5.102.9 Dependent
@tanstack/query-async-storage-persister 5.102.8 → 5.102.9 Dependent
@tanstack/query-broadcast-client-experimental 5.102.8 → 5.102.9 Dependent
@tanstack/query-devtools 5.102.8 → 5.102.9 Dependent
@tanstack/query-persist-client-core 5.102.8 → 5.102.9 Dependent
@tanstack/query-sync-storage-persister 5.102.8 → 5.102.9 Dependent
@tanstack/react-query 5.102.8 → 5.102.9 Dependent
@tanstack/react-query-devtools 5.102.8 → 5.102.9 Dependent
@tanstack/react-query-next-experimental 5.102.8 → 5.102.9 Dependent
@tanstack/react-query-persist-client 5.102.8 → 5.102.9 Dependent
@tanstack/solid-query 5.102.8 → 5.102.9 Dependent
@tanstack/solid-query-devtools 5.102.8 → 5.102.9 Dependent
@tanstack/solid-query-persist-client 5.102.8 → 5.102.9 Dependent
@tanstack/vue-query 5.102.8 → 5.102.9 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Sep 6, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11433

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11433

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11433

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 806caf3

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.87 KB (0%)
react minimal 8.84 KB (0%)

@sukvvon
sukvvon merged commit 8d19810 into main Sep 6, 2026
9 checks passed
@sukvvon
sukvvon deleted the test/react-preact-useinfinitequery-skiptoken-call-count branch September 6, 2026 14:23
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