Skip to content

test(*): rename the 'queryKey' test helper to 'createKey' since it creates keys for both queries and mutations - #12293

Merged
sukvvon merged 2 commits into
mainfrom
test/query-test-utils-rename-query-key-to-create-key
Oct 23, 2026
Merged

sukvvon merged 2 commits into
mainfrom
test/query-test-utils-rename-query-key-to-create-key

Conversation

@sukvvon

@sukvvon sukvvon commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

The queryKey helper in @tanstack/query-test-utils is used for both queryKey and mutationKey, so its name doesn't describe what it does and clashes with the queryKey option and context property in tests.

  • Rename queryKey.ts to createKey.ts and the helper to createKey, and update its JSDoc and tests.
  • Update all imports and calls across the test files of every package.
  • Change the key prefix from query_ to key-, since the keys are also used as mutation keys.

✅ 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 have followed the AI contribution policy and 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

  • Refactor
    • Replaced the query and mutation key-generation helper in test utilities with createKey. Test suites across supported frameworks now use the updated helper, including type tests. The generated keys remain unique, and existing query and mutation behavior and test expectations are unchanged. The former helper is no longer available from the test utilities.

@sukvvon sukvvon self-assigned this Oct 23, 2026
@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b9d6815

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

@nx-cloud

nx-cloud Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit b9d6815

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

☁️ Nx Cloud last updated this comment at 2026-10-23 06:16:53 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.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 82cc028 and b9d6815.

📒 Files selected for processing: 2
  • packages/query-test-utils/src/__tests__/createKey.test.ts
  • packages/query-test-utils/src/createKey.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The test utility replaces queryKey with exported createKey, which returns incrementing string-array keys. Tests across core and framework packages now use the new helper. Most test scenarios and expectations are unchanged.

Changes: Test key utility migration

Layer / File(s) Summary
Add and export createKey
packages/query-test-utils/src/*
The utility adds and exports createKey, which returns incrementing key-N keys. Tests verify the initial value and that consecutive calls return distinct keys.
Migrate test fixtures
packages/*/src/__tests__/*, packages/svelte-query/tests/*
Tests across query-core and the Angular, Lit, Preact, React, Solid, Svelte, and Vue packages use createKey instead of queryKey. The query-cache type test adds a queryKey filter check. The suspense-query props type test removes the placeholderData rejection check.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Merge Risk: ⚪ Minimal · up to b9d68

No actionable user or production risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed 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 27 functions across 52 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description includes all required template sections. It explains the rename, lists the affected updates, records the completed checklist items, and identifies the change as dev-only with no releas…
Title check Passed The title clearly and concisely describes the main change: renaming the queryKey test helper to createKey because it supports both query and mutation keys.
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.
Full details: Description check

Explanation

The description includes all required template sections. It explains the rename, lists the affected updates, records the completed checklist items, and identifies the change as dev-only with no release impact.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: b9d6815

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.76 KB (0%)
react minimal 8.59 KB (0%)

… to 'key-' since it is also used for mutation keys
@sukvvon
sukvvon force-pushed the test/query-test-utils-rename-query-key-to-create-key branch from 82cc028 to b9d6815 Compare October 23, 2026 06:09
@sukvvon
sukvvon merged commit d09972b into main Oct 23, 2026
9 checks passed
@sukvvon
sukvvon deleted the test/query-test-utils-rename-query-key-to-create-key branch October 23, 2026 06:32
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