Skip to content

test(vue-query): replace hardcoded query keys with 'queryKey()' utility#10524

Merged
sukvvon merged 1 commit intomainfrom
test/vue-query-replace-hardcoded-keys-with-queryKey
Apr 20, 2026
Merged

test(vue-query): replace hardcoded query keys with 'queryKey()' utility#10524
sukvvon merged 1 commit intomainfrom
test/vue-query-replace-hardcoded-keys-with-queryKey

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 20, 2026

🎯 Changes

Replace hardcoded query keys with the queryKey() utility from @tanstack/query-test-utils across vue-query test files, following the pattern used in other adapters (react-query, solid-query, etc.).

Files changed

Runtime tests (.test.ts):

  • queryOptions.test.ts
  • infiniteQueryOptions.test.ts
  • usePrefetchQuery.test.ts
  • usePrefetchInfiniteQuery.test.ts

Type tests (.test-d.ts):

  • queryOptions.test-d.ts
  • usePrefetchQuery.test-d.ts
  • usePrefetchInfiniteQuery.test-d.ts
  • useQueries.test-d.ts
  • useQuery.test-d.ts

Excluded

  • queryCache.test.ts: keeps hardcoded ['foo', ref('bar')] because the test's purpose is to verify ref unwrapping (the fixed values are assertion targets, not placeholders).

✅ 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
    • Standardized query key generation across multiple test suites for improved consistency in query option tests.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 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: 2c24c21d-ad49-42a7-a284-d46948605c9a

📥 Commits

Reviewing files that changed from the base of the PR and between 5b5d1db and 2b56e27.

📒 Files selected for processing (9)
  • packages/vue-query/src/__tests__/infiniteQueryOptions.test.ts
  • packages/vue-query/src/__tests__/queryOptions.test-d.ts
  • packages/vue-query/src/__tests__/queryOptions.test.ts
  • packages/vue-query/src/__tests__/usePrefetchInfiniteQuery.test-d.ts
  • packages/vue-query/src/__tests__/usePrefetchInfiniteQuery.test.ts
  • packages/vue-query/src/__tests__/usePrefetchQuery.test-d.ts
  • packages/vue-query/src/__tests__/usePrefetchQuery.test.ts
  • packages/vue-query/src/__tests__/useQueries.test-d.ts
  • packages/vue-query/src/__tests__/useQuery.test-d.ts

📝 Walkthrough

Walkthrough

Test files in the vue-query package have been updated to use the queryKey() factory function from @tanstack/query-test-utils instead of hard-coded query key arrays across multiple test suites for queryOptions, usePrefetchInfiniteQuery, usePrefetchQuery, useQueries, useQuery, and infiniteQueryOptions.

Changes

Cohort / File(s) Summary
Infinite Query Tests
packages/vue-query/src/__tests__/infiniteQueryOptions.test.ts
Replaced hard-coded ['key'] tuple with queryKey() factory call for the queryKey property in test input object.
Query Options Tests
packages/vue-query/src/__tests__/queryOptions.test.ts, queryOptions.test-d.ts
Replaced hard-coded query key literals with queryKey() factory and updated getter-based keys to use spread syntax (e.g., [...queryKey(), ...]) in type-definition tests.
Prefetch Infinite Query Tests
packages/vue-query/src/__tests__/usePrefetchInfiniteQuery.test.ts, usePrefetchInfiniteQuery.test-d.ts
Converted hard-coded query key arrays to dynamically generated keys via queryKey() utility; updated ref-based keys to use spread syntax combining factory output with ref values (e.g., [...queryKey(), ref('id')]).
Prefetch Query Tests
packages/vue-query/src/__tests__/usePrefetchQuery.test.ts, usePrefetchQuery.test-d.ts
Replaced fixed query key arrays with generated queryKey() values; updated ref and reactive test cases to combine generated keys with values via spread syntax.
General Query Tests
packages/vue-query/src/__tests__/useQueries.test-d.ts, useQuery.test-d.ts
Replaced literal ['key'] arrays with queryKey() factory calls in type-definition and ref/computed option scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

package: vue-query

Poem

🐰 Query keys dance in factory light,
Hard-coded strings fade from sight,
Spread syntax spreads the joy around,
With queryKey() test helpers found,
Tests now spring with freshened might!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: replacing hardcoded query keys with a queryKey() utility across vue-query test files, which aligns with the changeset.
Description check ✅ Passed The description includes all required template sections, provides clear context about the changes, lists affected files, explains exclusions, and completes the checklist with appropriate selections.
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/vue-query-replace-hardcoded-keys-with-queryKey

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 20, 2026

View your CI Pipeline Execution ↗ for commit 2b56e27

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

☁️ Nx Cloud last updated this comment at 2026-04-20 04:56:27 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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 20, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 2b56e27

@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 self-assigned this Apr 20, 2026
@sukvvon sukvvon merged commit 599e51d into main Apr 20, 2026
10 checks passed
@sukvvon sukvvon deleted the test/vue-query-replace-hardcoded-keys-with-queryKey branch April 20, 2026 05:08
Ephem pushed a commit to Ephem/react-query that referenced this pull request Apr 23, 2026
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