Skip to content

test(query-core/utils): add tests for 'undefined' key properties and 'isValidTimeout' validation - #11013

Merged
sukvvon merged 4 commits into
TanStack:mainfrom
whizzkid1452:feature/query-key-timeout-test-coverage
Jul 17, 2026
Merged

test(query-core/utils): add tests for 'undefined' key properties and 'isValidTimeout' validation#11013
sukvvon merged 4 commits into
TanStack:mainfrom
whizzkid1452:feature/query-key-timeout-test-coverage

Conversation

@whizzkid1452

@whizzkid1452whizzkid1452 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

Adds tests for query-core utils behavior that was executed but never asserted:

  • hashKey / partialMatchKey: query key objects with undefined-valued properties are treated the same as objects without those properties.
  • isValidTimeout: accepts finite non-negative numbers and rejects -1, NaN, Infinity, non-numbers and undefined. This function gates staleTime, gcTime and refetchInterval, but had no direct test coverage.

✅ 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).

Clarify isValidTimeout with Number.isFinite, add regression tests for undefined query-key object properties, and fix TanStack branding in community resources.
@coderabbitai

coderabbitaiBot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updates isValidTimeout to require finite non-negative numbers, adds tests for timeout and query-key utility behavior, and corrects the capitalization of the Query Visualizer documentation entry.

Changes

isValidTimeout Validation Update

Layer / File(s)Summary
Finite timeout validation and query-key tests
packages/query-core/src/utils.ts, packages/query-core/src/__tests__/utils.test.tsx
isValidTimeout now requires finite non-negative values, with tests covering valid and invalid inputs plus undefined-property behavior in hashKey and partialMatchKey.

Documentation Fix

Layer / File(s)Summary
Community resources title fix
docs/community-resources.md
Corrected “Tanstack Query Visualizer” to “TanStack Query Visualizer”.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Title check✅ PassedThe title clearly describes the added query-core tests and timeout validation change, though it omits the minor docs-only capitalization fix.
Description check✅ PassedThe description matches the template with Changes, Checklist, and Release Impact sections, and the key fields are filled in.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Comment threaddocs/community-resources.md Outdated
Comment threadpackages/query-core/src/utils.ts Outdated
@nx-cloud

nx-cloudBot commented Jul 17, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a1c97b2

CommandStatusDurationResult
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded8m 5sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 54sView ↗

☁️ Nx Cloud last updated this comment at 2026-07-17 03:33:02 UTC

@pkg-pr-new

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: a1c97b2

@sukvvonsukvvon changed the title test(query-core): cover query key undefined and timeout validationtest(query-core/utils): add tests for 'undefined' object properties in 'hashKey'/'partialMatchKey' and 'isValidTimeout'Jul 17, 2026
@sukvvonsukvvon changed the title test(query-core/utils): add tests for 'undefined' object properties in 'hashKey'/'partialMatchKey' and 'isValidTimeout'test(query-core/utils): add tests for 'undefined' key properties and 'isValidTimeout' validationJul 17, 2026
@sukvvon
sukvvon merged commit a9aa23f into TanStack:mainJul 17, 2026
9 checks passed
@whizzkid1452
whizzkid1452 deleted the feature/query-key-timeout-test-coverage branch July 21, 2026 08:44
Sign up for freeto 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.

2 participants

@whizzkid1452@sukvvon