skills/testing/tech-vitest/SKILL.md
Vitest testing framework for modern JavaScript. Unit and integration tests with Jest-compatible API, native TypeScript, Vite integration, MSW v2 for HTTP mocking, and snapshot testing. Covers vi.mock hoisting, fake timers, test isolation, and async patterns. Use when writing tests with Vitest, mocking dependencies, or setting up test infrastructure.
npx skillsauth add ravnhq/ai-toolkit tech-vitestInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Fast, Vite-powered testing framework with Jest-compatible API and native ESM. Vitest excels at:
vi.mock() for modules, MSW v2 for HTTP requests, fake timers for time-dependent codeCore challenge: test isolation. Vitest's hoisting rules for vi.mock() require vi.hoisted() for shared mock state. MSW v2 changes handler APIs. Snapshot updates must be intentional.
When setting up tests or adding test cases:
vi.mock() with hoisting for modules, MSW for HTTP, fake timers for timevi.hoisted() if mocks need variables from test scopebeforeAll(), reset in afterEach()vitest --watch with coverage checksTests are organized by concern:
vi.mock(), vi.hoisted(), partial mocking with importOriginalvi.fn() with return values, implementations, and call trackingvi.spyOn() to watch object methods without replacingsetupServer(), per-test overridesvi.useFakeTimers(), vi.setSystemTime(), timer advancementtoMatchSnapshot(), inline snapshots, edge casesbeforeEach, afterEach, fixtures, setup filesSee rules/ for implementation patterns and examples.
User: "Mock the API client in this Vitest test so it returns a fake response."
Expected behavior: Use tech-vitest guidance, apply vi.mock() with hoisting rules and MSW patterns.
User: "Set up a PostgreSQL database schema for user accounts."
Expected behavior: Do not prioritize tech-vitest; choose a more relevant skill or proceed without it.
Error: Placing vi.mock() inside a condition
Cause: vi.mock() is hoisted; conditions are ignored, leading to unexpected module state
Solution: Move mocks to file top; use vi.hoisted() for conditional mock state
Error: Updating snapshots without reviewing changes
Cause: Snapshots bypass assertions; unexpected changes hide bugs
Solution: Always review diffs in --ui mode before accepting with -u
Error: Cannot access 'mockData' before initialization
Cause: Variables defined outside vi.mock() are not accessible in the factory (hoisting)
Solution: Wrap in vi.hoisted() to define shared mock state at the top level
Error: Mock handler never invoked; real HTTP request fires
Cause: MSW server not started or wrong handler method (http vs graphql)
Solution: Call server.listen() in beforeAll(); check handler verb matches request
Error: Test passes locally but fails in CI
Cause: Fake timers not reset between tests; time drifts across suite
Solution: Call vi.useRealTimers() in afterEach() without fail
testing
Transform user requests into detailed, precise prompts for AI models. Use when users say 'promptify', 'promptify this', 'rewrite this prompt', 'make this prompt better/more specific', or explicitly request prompt engineering or improvement of their request for better AI responses.
tools
Manage AI skills from the Ravn AI Toolkit via corvus CLI — install, update, remove, search, and configure skills for any project. Use when: (1) Installing AI skills into a project, (2) Updating installed skills to latest versions, (3) Browsing or searching available skills, (4) Configuring global or per-project skill sets, (5) Troubleshooting corvus setup. Triggers on: "install skills", "add skills", "update skills", "corvus", "skill manager", "browse skills", "set up AI rules".
development
Generate a gallery of design variations for a UI component. Takes an existing component (referenced by name, pasted code, or screenshot) and produces N distinct rendered alternatives in a single comparison page. Use when exploring visual directions, generating mockups, comparing design approaches for a component, creating A/B candidates, or when anyone says "show me options" or "give me variations" for a UI element.
tools
Create custom QA agent personalities for project-specific testing needs. Guided builder that asks about the specialty, tools, and test scenarios, then generates a personality file and registers it in the QA config. Trigger on "create a QA personality", "add a custom test agent", "build a webhook tester", or when the user needs a project-specific QA agent. Also triggered by /qa-create-personality.