Skip to content

test(query-core/queryObserver): add test for skipping refetch when 'retryOnMount' is false and query is in error state#10518

Merged
sukvvon merged 1 commit intomainfrom
test/query-core-queryObserver-retryOnMount-false
Apr 19, 2026
Merged

test(query-core/queryObserver): add test for skipping refetch when 'retryOnMount' is false and query is in error state#10518
sukvvon merged 1 commit intomainfrom
test/query-core-queryObserver-retryOnMount-false

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 19, 2026

🎯 Changes

Add a test to verify that QueryObserver does not refetch on mount when retryOnMount: false is set and the query is already in error state.

This covers the options.retryOnMount === false branch in shouldLoadOnMount (queryObserver.ts:755).

✅ 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

  • Tests
    • Added test coverage for query observer behavior to ensure queries do not re-execute upon remounting when retry and retryOnMount are disabled.

…etryOnMount' is false and query is in error state
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9e662806-b309-42c3-bd2e-92e4f92d2057

📥 Commits

Reviewing files that changed from the base of the PR and between 430e988 and 5723908.

📒 Files selected for processing (1)
  • packages/query-core/src/__tests__/queryObserver.test.tsx

📝 Walkthrough

Walkthrough

A test case is added to verify that QueryObserver respects the retryOnMount: false option by preventing query function re-invocation when mounting an observer after a prior failed query and unsubscription.

Changes

Cohort / File(s) Summary
QueryObserver Test
packages/query-core/src/__tests__/queryObserver.test.tsx
Added test case asserting that a new QueryObserver with retryOnMount: false does not reinvoke the query function on mount after prior failure and unsubscription.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A test hops in, so spry and bright,
Checking that retryOnMount works right,
No second calls when false we say,
The observer knows—just stay away! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a test for QueryObserver behavior when retryOnMount is false and query is in error state.
Description check ✅ Passed The description includes all required sections with complete information: detailed changes explanation, fully checked checklist items, and correct release impact assessment.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/query-core-queryObserver-retryOnMount-false

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 19, 2026

View your CI Pipeline Execution ↗ for commit 5723908

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 43s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-19 09:35:26 UTC

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@sukvvon sukvvon self-assigned this Apr 19, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 19, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 5723908

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.99 KB (0%)
react minimal 9.02 KB (0%)

@sukvvon sukvvon merged commit 08a4d2b into main Apr 19, 2026
13 of 14 checks passed
@sukvvon sukvvon deleted the test/query-core-queryObserver-retryOnMount-false branch April 19, 2026 09:43
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