Skip to content

test(*): assert exact values instead of loose matchers#11057

Merged
sukvvon merged 1 commit into
mainfrom
test/tighten-loose-matchers-to-exact-values
Jul 12, 2026
Merged

test(*): assert exact values instead of loose matchers#11057
sukvvon merged 1 commit into
mainfrom
test/tighten-loose-matchers-to-exact-values

Conversation

@sukvvon

@sukvvon sukvvon commented Jul 12, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Several tests used loose matchers that pass as long as something is present, without checking the actual value. Where the thrown/forwarded value is deterministic (thrown by the test itself, or a fixed source message), the assertions are tightened to the exact value.

  • lit-queryinfinite-and-options, mutation-controllertoBeInstanceOf(Error)toEqual(new Error('<message>')). Each error is thrown by the test's own queryFn/mutationFn (next-page-failed, negative-not-allowed, reset-target), and the sibling rejects.toThrow('<message>') already checks the same message, so the error object is now checked to match it too.
  • query-coretimeoutManager — the second argument of the provider-switch warning was expect.anything() (any non-null value); it now asserts the exact { previous, provider } payload the source passes.
  • query-devtoolsExplorer — the clipboard copy failure logs console.error('Failed to copy: ', err); expect.any(Error) → the exact new Error('denied') the test's writeText mock rejects with.
  • vue-queryuseQueryClient — bare toThrow()toThrow('<message>') for the two guards (No 'queryClient' found ... and vue-query hooks can only be used inside setup() ...), which the source throws unconditionally.

✅ Checklist

🚀 Release Impact

  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Improved test coverage by verifying exact error values and messages across pagination, mutations, timeout handling, clipboard failures, and Vue query-client usage.
    • Added more precise validation for timeout-provider warnings and missing query-client guidance.

@sukvvon sukvvon self-assigned this Jul 12, 2026
@nx-cloud

nx-cloud Bot commented Jul 12, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a73f841

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

☁️ Nx Cloud last updated this comment at 2026-07-12 17:26:46 UTC

@coderabbitai

coderabbitai Bot commented Jul 12, 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 47f0570c-5d1d-45d2-b654-628ef1e817ee

📥 Commits

Reviewing files that changed from the base of the PR and between fb8f474 and a73f841.

📒 Files selected for processing (5)
  • packages/lit-query/src/tests/infinite-and-options.test.ts
  • packages/lit-query/src/tests/mutation-controller.test.ts
  • packages/query-core/src/__tests__/timeoutManager.test.tsx
  • packages/query-devtools/src/__tests__/Explorer.test.tsx
  • packages/vue-query/src/__tests__/useQueryClient.test.ts

📝 Walkthrough

Walkthrough

Tests across Lit Query, Query Core, Devtools, and Vue Query now assert exact error values, warning metadata, and thrown messages instead of generic error matchers.

Changes

Error assertion tightening

Layer / File(s) Summary
Lit Query error values
packages/lit-query/src/tests/*
Pagination and mutation tests now verify exact Error values and messages.
Core and Devtools error details
packages/query-core/src/__tests__/timeoutManager.test.tsx, packages/query-devtools/src/__tests__/Explorer.test.tsx
Tests now verify timeout-provider metadata and the concrete clipboard failure error.
Vue Query thrown messages
packages/vue-query/src/__tests__/useQueryClient.test.ts
Tests now verify exact messages for missing queryClient context and usage outside setup().

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

Possibly related PRs

Suggested labels: package: query-devtools

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: tightening tests to assert exact values instead of loose matchers.
Description check ✅ Passed The description matches the template and includes changes, checklist, and release impact sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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/tighten-loose-matchers-to-exact-values

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

@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

pkg-pr-new Bot commented Jul 12, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: a73f841

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.13 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon merged commit 045c947 into main Jul 12, 2026
9 checks passed
@sukvvon sukvvon deleted the test/tighten-loose-matchers-to-exact-values branch July 12, 2026 17:27
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