skillfed

vitest

Vitest is a next-generation test framework powered by Vite, delivering rapid test execution through HMR and native ESM support. It offers built-in TypeScript integration, Jest-compatible APIs for easy migration, and component testing for React and Vue projects.

Vitest enables fast TypeScript unit testing with Vite-native performance and ESM-first design.

AI-generated summary based on this skill's SKILL.md

62 18 MIT updated by bobmatnyc

Install

bobmatnyc/claude-mpm-skills/vitest · repository language: Python

git clone https://github.com/bobmatnyc/claude-mpm-skills
cp -r claude-mpm-skills/toolchains/typescript/testing/vitest ~/.claude/skills/vitest
npx skillfed install bobmatnyc/claude-mpm-skills/vitest

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What is vitest and how does it compare to Jest?

Vitest is a next-generation test framework powered by Vite that delivers rapid test execution through HMR and native ESM support. Unlike Jest, Vitest offers built-in TypeScript integration and Jest-compatible APIs for easy migration, making it ideal for modern projects. Vitest excels at speed through Vite's transformation pipeline and hot module reloading during watch mode.

How do I set up vitest for TypeScript/JavaScript unit testing?

Vitest provides straightforward setup for TypeScript and JavaScript projects. Install vitest via npm or yarn, then create a vitest.config.ts file to configure your test environment. Vitest automatically detects and transpiles TypeScript files without additional configuration. Define your test files with .test.ts or .spec.ts extensions, then run vitest in watch mode or CI mode for single runs.

Can vitest be used for component testing with React and Vue?

Yes, Vitest supports component testing for both React and Vue projects when paired with Testing Library. Vitest component testing enables you to test component rendering, user interactions, and state changes. The framework integrates seamlessly with Testing Library's query methods and assertions, providing a familiar testing experience for component-focused development.

How do I migrate from Jest to vitest?

Migrating from Jest to Vitest is straightforward because Vitest maintains Jest-compatible APIs. Most test files require minimal changes—simply update import statements and configuration files. Vitest supports Jest's expect matchers, mocking utilities, and setup patterns. Run vitest with your existing test suite to identify any compatibility issues, then adjust as needed for Vitest-specific features like native ESM support.

What mocking and spies capabilities does vitest provide?

Vitest offers comprehensive mocking and spies functionality including function mocking, module mocking, and timer mocking for fake timers. You can spy on function calls, track arguments, and control return values. Vitest supports vi.mock() for module mocking, vi.fn() for function spies, and vi.useFakeTimers() for time-based testing, all compatible with Jest's mocking patterns.

How do I configure code coverage and run vitest in watch mode?

Vitest supports code coverage configuration through built-in providers like c8 or Istanbul. Enable coverage in your vitest.config.ts file and specify thresholds and reporters. Watch mode with HMR allows tests to re-run automatically when files change, providing instant feedback during development. Use vitest --watch for development and vitest --run for CI environments.

SKILL.md

rendered from the published skill — quoted content, verbatim

Vitest - Modern TypeScript Testing

Overview

Vitest is a next-generation test framework powered by Vite, designed for modern TypeScript/JavaScript projects. It provides blazing-fast test execution through HMR-based test running, native ESM support, and first-class TypeScript integration.

Key Features: - ⚡

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 4 files
toolchains/typescript/testing/vitest/CODE_EXAMPLES_INDEX.md
toolchains/typescript/testing/vitest/IMPLEMENTATION_SUMMARY.md
toolchains/typescript/testing/vitest/SKILL.md
toolchains/typescript/testing/vitest/metadata.json

Related skills

Tags

test-runner vite-ecosystem esm-native jest-alternative component-testing type-safe-testing hot-reload-testing coverage-tools mock-framework typescript-first