react-query-test-harness-fixer
Skill0 starsChanged 30 days agoMITView on GitHub
Fix React/Vitest test failures for TanStack React Query components and jsdom side effects. Use when React Query component tests fail under Vitest or jsdom with hangs, act warnings, or side-effect leaks.
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this workflow when test setup has fallen behind the app's React Query and browser dependencies.
- Very specific: line 21
Create a new QueryClient per helper or per test and set retry: false for deterministic failures.
- Very specific: line 24
Wait for async UI with findBy...
- Very specific: line 30
Put durable browser shims in shared test setup for matchMedia and HTMLCanvasElement.getContext.
- Very specific: line 36
Do not share one QueryClient across unrelated tests.
- Distinctive: line 37
Do not assert on post-query UI before the fetch promise has resolved.
- Distinctive: line 38
Do not leave broad fetch mocks or global state behind between tests.
- Distinctive: line 42
Run the targeted test file first.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Query Test Harness Fixer
Use this workflow when test setup has fallen behind the app's React Query and browser dependencies.
Read First
- The failing test file
- The page or component under test
- Shared test setup such as
client/tests/setup.ts - Any route or data modules the component depends on
Workflow
- Identify every
useQuery,useMutation, and route dependency used by the rendered component. - Wrap the render path in a fresh
QueryClientProvider. - Create a new
QueryClientper helper or per test and setretry: falsefor deterministic failures. - Stub network calls at the boundary the component actually uses. Return stable list and detail responses.
- Recreate routing context with the same router the app uses, such as
memoryLocationforwouter. - Wait for async UI with
findBy...orwaitForafter the query resolves. - Neutralize browser-only side effects.
Browser API Rules
- Mock
navigator.clipboardin the test when copy behavior is asserted. - Put durable browser shims in shared test setup for
matchMediaandHTMLCanvasElement.getContext. - Mock side-effect libraries such as
canvas-confettidirectly when the animation is not part of the assertion. - Clear
localStorageand reset globals after each test.
Anti-Patterns
- Do not share one
QueryClientacross unrelated tests. - Do not assert on post-query UI before the fetch promise has resolved.
- Do not leave broad fetch mocks or global state behind between tests.
Validation
- Run the targeted test file first.
- Run
npm.cmd run test. - Run
npm.cmd run check.
In this repository38 other files it gives its agents.
- AGENTS.mdAGENTS.md
- 3d-bloom-sceneSkill
- api-design-reviewSkill
- api-drift-scoutSkill
- api-prompt-optimizerSkill
- autonomy-mapSkill
- behavior-spec-canvasSkill
- cloudflare-deploySkill
- database-designSkill
- docker-debugSkill
- eval-frameworkSkill
- force-graph-3dSkill
- gh-fix-ciSkill
- git-workflowsSkill
- glassmorphic-uiSkill
- imagegenSkill
- interactive-artifact-generatorSkill
- pdfSkill
- photo-geolocatorSkill
- playwright-interactiveSkill
- playwrightSkill
- pr-shell-safety-packSkill
- repo-first-vercel-buildSkill
- screenshotSkill
- scrutiny-feature-reviewerSkill
- sdk-ui-override-specialistSkill
- security-auditSkill
- security-best-practicesSkill
- security-ownership-mapSkill
- security-threat-modelSkill
- seeded-catalog-syncSkill
- speechSkill
- testing-strategySkill
- transcribeSkill
- user-testing-flow-validatorSkill
- windows-cli-wsl-repairSkill
- windows-node-sandbox-troubleshootingSkill
- workerSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

