Skip to content

test(vue-query-devtools): set up vitest environment with production fallback test#10629

Draft
sukvvon wants to merge 4 commits intomainfrom
test/vue-query-devtools-set-up-vitest-environment
Draft

test(vue-query-devtools): set up vitest environment with production fallback test#10629
sukvvon wants to merge 4 commits intomainfrom
test/vue-query-devtools-set-up-vitest-environment

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 3, 2026

🎯 Changes

Set up the vitest environment for vue-query-devtools and add tests covering the production fallback in index.ts.

  • Switch vite.config.ts to use defineConfig from vitest/config and add a test block with jsdom environment.
  • Add test:lib / test:lib:dev scripts to package.json.
  • Add VueQueryDevtools.test.ts and VueQueryDevtoolsPanel.test.ts, each with a should return null in non-development environments case that uses vi.stubEnv('NODE_ENV', 'production') + vi.resetModules() + try/finally cleanup for deterministic verification.

The tests verify only the index.ts production fallback (no SFC mount), so no @testing-library/vue is introduced. This mirrors the deterministic env pattern used in react-query-devtools (#10627) and preact-query-devtools (#10628).

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with `pnpm run test:lib` (2/2 passed).

🚀 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

    • Added tests to verify DevTools components return null in production and to ensure environment and module state are properly isolated between tests.
  • Chores

    • Added library test scripts and updated test configuration to run Vitest with coverage, jsdom, and improved TypeScript/type-checking and mock restoration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09220073-9e97-4008-ab07-0bd31308ded7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Vitest test setup to the vue-query-devtools package: new test scripts, a Vitest test block in the Vite config, and two tests that assert devtools exports return null when NODE_ENV is production.

Changes

Vitest test infra + production-smoke tests

Layer / File(s) Summary
Test scripts
packages/vue-query-devtools/package.json
Adds test:lib (runs vitest) and test:lib:dev (runs test:lib --watch).
Test runner config
packages/vue-query-devtools/vite.config.ts
Imports defineConfig from vitest/config and adds a test block configuring name, dir (./src), jsdom environment, coverage include/exclude, typecheck: { enabled: true }, and restoreMocks: true.
Smoke tests
packages/vue-query-devtools/src/__tests__/VueQueryDevtools.test.ts, packages/vue-query-devtools/src/__tests__/VueQueryDevtoolsPanel.test.ts
Adds tests that stub NODE_ENV to production, reset modules, dynamically import the package entry, assert each exported factory returns null, and restore env/modules in finally blocks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I nibble logs and sniff the ground,
Tests now run with vitest sound.
Production stubs, modules neat,
No stray state beneath my feet.
Hooray — the devtools tests complete! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: setting up Vitest with a production fallback test for vue-query-devtools.
Description check ✅ Passed The description covers all required template sections with complete information about changes, testing performed, and release impact assessment.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/vue-query-devtools-set-up-vitest-environment

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

@sukvvon sukvvon self-assigned this May 3, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 3, 2026

View your CI Pipeline Execution ↗ for commit f658265

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

☁️ Nx Cloud last updated this comment at 2026-05-03 18:26:23 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

🚀 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 May 3, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: f658265

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

size-limit report 📦

Path Size
react full 12.1 KB (0%)
react minimal 9.07 KB (0%)

@sukvvon sukvvon marked this pull request as draft May 3, 2026 14:46
@sukvvon
Copy link
Copy Markdown
Collaborator Author

sukvvon commented May 3, 2026

CI's Test check is failing with TS6053: File '...tsup.config.bundled_*.mjs' not found. — this is the known race condition fixed by #10522. Once that lands, this should pass on re-run.

CI run: https://github.com/TanStack/query/actions/runs/25282211546/job/74121119451

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