Skip to content

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

Merged
sukvvon merged 5 commits intomainfrom
test/vue-query-devtools-set-up-vitest-environment
May 4, 2026
Merged

chore(vue-query-devtools): set up vitest environment with production fallback test#10629
sukvvon merged 5 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 test suites to verify DevTools components return null in production and to ensure environment and module state are isolated between tests.
  • Chores

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 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: a6a269fd-8e43-485f-8737-6f0b1239c3f5

📥 Commits

Reviewing files that changed from the base of the PR and between 3e2733d and a1f7fb0.

📒 Files selected for processing (1)
  • packages/vue-query-devtools/vite.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/vue-query-devtools/vite.config.ts

📝 Walkthrough

Walkthrough

Adds Vitest-based tests and runner configuration to the vue-query-devtools package: new npm test scripts, a Vitest test block in the package Vite config, and two smoke 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 pnpm run test:lib --watch).
Test runner config
packages/vue-query-devtools/vite.config.ts
Imports defineConfig and mergeConfig from vitest/config, imports package.json, and adds a test block: name from package, dir: './src', watch: false, environment: 'jsdom', Istanbul 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', call vi.resetModules() before dynamic import('..'), assert each export returns null, and use try/finally to vi.unstubAllEnvs() and vi.resetModules() to avoid cross-test contamination.

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 accurately describes the main change: setting up vitest environment with production fallback tests for vue-query-devtools.
Description check ✅ Passed The description provides detailed information about all changes, follows the template structure with 🎯 Changes and ✅ Checklist sections, and marks the PR as dev-only (no changeset needed).
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 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-devtools-set-up-vitest-environment

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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 a1f7fb0

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

☁️ Nx Cloud last updated this comment at 2026-05-04 08:57:25 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: a1f7fb0

@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

@sukvvon sukvvon changed the title test(vue-query-devtools): set up vitest environment with production fallback test chore(vue-query-devtools): set up vitest environment with production fallback test May 4, 2026
@sukvvon sukvvon marked this pull request as ready for review May 4, 2026 09:26
@sukvvon sukvvon merged commit c8e1bde into main May 4, 2026
8 checks passed
@sukvvon sukvvon deleted the test/vue-query-devtools-set-up-vitest-environment branch May 4, 2026 09:31
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