smithery.ai

vitest-expert

Create organized, comprehensive, and efficient unit tests with Vitest, ensuring high code quality and stability.

First seen May 1, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,651 B
  • docs SUMMARY.md 133 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

SKILL.md

Guidelines for UNIT

VITEST

  • Leverage the vi object for test doubles - Use vi.fn() for function mocks, vi.spyOn() to monitor existing functions, and vi.stubGlobal() for global mocks. Prefer spies over mocks when you only need to verify interactions without changing behavior.
  • Master vi.mock() factory patterns - Place mock factory functions at the top level of your test file, return typed mock implementations, and use mockImplementation() or mockReturnValue() for dynamic control during tests. Remember the factory runs before imports are processed.
  • Create setup files for reusable configuration - Define global mocks, custom matchers, and environment setup in dedicated files referenced in your vitest.config.ts. This keeps your test files clean while ensuring consistent test environments.
  • Use inline snapshots for readable assertions - Replace complex equality checks with expect(value).toMatchInlineSnapshot() to capture expected output directly in your test file, making changes more visible in code reviews.
  • Monitor coverage with purpose and only when asked - Configure coverage thresholds in vitest.config.ts to ensure critical code paths are tested, but focus on meaningful tests rather than arbitrary coverage percentages.
  • Make watch mode part of your workflow - Run vitest --watch during development for instant feedback as you modify code, filtering tests with -t to focus on specific areas under development.
  • Explore UI mode for complex test suites - Use vitest --ui to visually navigate large test suites, inspect test results, and debug failures more efficiently during development.
  • Handle optional dependencies with smart mocking - Use conditional mocking to test code with optional dependencies by implementing vi.mock() with the factory pattern for modules that might not be available in all environments.
  • Configure jsdom for DOM testing - Set environment: 'jsdom' in your configuration for frontend component tests and combine with testing-library utilities for realistic user interaction simulation.
  • Structure tests for maintainability - Group related tests with descriptive describe blocks, use explicit assertion messages, and follow the Arrange-Act-Assert pattern to make tests self-documenting.
  • Leverage TypeScript type checking in tests - Enable strict typing in your tests to catch type errors early, use expectTypeOf() for type-level assertions, and ensure mocks preserve the original type signatures.