Vitest Expert - CLAUDE.md Rules for Claude Code
Transform Claude into a Vitest specialist with deep knowledge of fast unit testing, mocking, coverage, watch mode, and Vite-native test configuration.
Open the source and read safety notes before installing.
Privacy notes
- Rules reference API keys used in integration tests; load them from environment variables, never from committed config.
Schema details
- Install type
- copy
- Troubleshooting
- No
Full copyable content
You are an expert Vitest developer focused on fast, deterministic unit tests.
## Test design
- Test behavior through public APIs; avoid asserting private implementation details.
- Keep tests isolated with fresh module state and explicit setup/teardown.
## Mocking
- Use `vi.mock` and `vi.spyOn` for boundaries; restore mocks after each test.
- Prefer dependency injection over deep module mocking when possible.
## Configuration
- Reuse Vite aliases and plugins in `vitest.config` for parity with app builds.
- Enable coverage thresholds for critical modules and fail CI on regressions.About this resource
Vitest Expert
Use these rules when writing or reviewing Vitest unit and integration tests.
Fast, isolated tests
Favor small tests with clear arrange/act/assert structure. Reset mocks and module state between tests so order never matters.
Mocking boundaries
Mock network, filesystem, and clock boundaries with Vitest utilities. Keep business logic under test real unless the dependency is non-deterministic.
Vite integration
Share resolve aliases, environment definitions, and transform settings between app and test configs so tests exercise the same module graph as production builds.
Coverage and CI
Track meaningful coverage on core modules, run Vitest in CI with --run, and use watch mode only for local development.
References
Source citations
Add this badge to your README
How it compares
Vitest Expert - CLAUDE.md Rules for Claude Code side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | Vitest Expert - CLAUDE.md Rules for Claude Code Transform Claude into a Vitest specialist with deep knowledge of fast unit testing, mocking, coverage, watch mode, and Vite-native test configuration. Open dossier | Vitest Test-Driven Development Rule for Claude Code A CLAUDE.md rule that drives test-first development with Vitest: write a failing Vitest test, add the minimum code to pass, then refactor. It covers vitest.config setup, expect assertions, vi mocks and fake timers, coverage thresholds, and running specs in watch mode or once with vitest run. Open dossier | Playwright Expert - CLAUDE.md Rules for Claude Code Transform Claude into a Playwright specialist with deep knowledge of browser automation, resilient locators, fixtures, tracing, and CI-friendly end-to-end testing. Open dossier | .NET and C# Expert - CLAUDE.md Rules for Claude Code A CLAUDE.md rule set that turns Claude into a senior .NET reviewer aligned with current Microsoft guidance across ASP.NET Core, Entity Framework Core, asynchronous programming, typed options, and automated testing. Open dossier |
|---|---|---|---|---|
| Trust | ||||
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety · Privacy ✓ | Safety ✓ Privacy ✓ | Safety · Privacy ✓ | Safety · Privacy ✓ |
| Category | rules | rules | rules | rules |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | jaso0n0818 | JSONbored | jaso0n0818 | jaso0n0818 |
| Added | 2026-06-17 | 2025-10-25 | 2026-06-17 | 2026-06-13 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | — missing | ✓Guidance only — this rule adds no executable code, but its examples install dependencies (npm ci), run the Vitest CLI, and execute generated test suites locally and in CI; review and run them yourself rather than auto-executing. The CI sample runs tests on every push and pull request via GitHub Actions and uploads coverage to a third-party service (Codecov), which you must configure before use. | — missing | — missing |
| Privacy notes | ✓Rules reference API keys used in integration tests; load them from environment variables, never from committed config. | ✓The async examples mock the global fetch against endpoints like /api/users and write coverage reports (lcov, html) to a local coverage/ directory; the CI sample additionally uploads lcov coverage to Codecov. | ✓Rules reference test credentials and environment URLs; store them in CI secrets or local env files, never in committed test sources. | ✓Rules reference dotnet user-secrets and Azure Key Vault for credential storage; secrets must never be committed to source control or hard-coded in application settings files. |
| Prerequisites | — none listed | — none listed | — none listed | — none listed |
| Install | — | — | — | — |
| Config | — | — | — | — |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Signals
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.