vitest_skill

This skill helps you accelerate test development with Vitest by providing Jest-compatible APIs, in-source testing tips, and fast Vite-backed execution.
  • TypeScript

8

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill joncrangle/.dotfiles --skill vitest

  • SKILL.md1.9 KB

Overview

This skill specializes in Vitest, the fast unit test framework built on Vite, with a focus on TypeScript-friendly, in-source testing and native ESM support. It helps configure, migrate, and optimize tests while preserving Jest-like APIs using vi.* globals. The skill also includes guidance for dotfiles and install scripts to make Vitest part of your developer environment.

How this skill works

It inspects project layout for vitest.config.ts or vite.config.ts to detect global settings, test environment (jsdom/node), and alias resolution. It suggests migration steps from Jest by replacing jest.* usages with vi.* and ensuring ESM imports and proper export styles. It checks for common pitfalls like CommonJS require, module.exports, or unnecessary tsc test steps and suggests fixes and performant configs.

When to use it

  • Setting up fast unit tests for TypeScript projects using Vite
  • Migrating a codebase from Jest to Vitest while keeping similar test APIs
  • Running in-source tests (tests colocated with source files) for rapid feedback
  • Configuring test environment (jsdom vs node) or enabling globals in vitest.config.ts
  • Integrating Vitest into dotfiles or developer install scripts for consistent setups

Best practices

  • Prefer vi.fn, vi.mock, and vi.spyOn instead of any jest.* globals
  • Use import/export and ESM module syntax; avoid require and module.exports
  • Reuse vite.config.ts for shared build/test resolution and aliases
  • Avoid adding tsc compilation to test runner — rely on Vitest's esbuild path for speed
  • Run vitest in watch during dev and vitest run in CI; enable coverage only in CI to save local cycles

Example use cases

  • Add vitest.config.ts to a TypeScript repo and enable globals and jsdom for DOM tests
  • Convert existing Jest tests by replacing jest.mock/jest.fn with vi.mock/vi.fn and switching require to import
  • Bundle Vitest setup into dotfiles and install scripts to provision consistent developer environments
  • Use in-source tests (.test.ts next to implementation) for faster edit-test loops with vitest watch mode
  • Enable vitest ui for a browser-based test runner during manual QA

FAQ

Replace jest.mock/jest.fn with vi.mock/vi.fn (and use vi.spyOn). Ensure files use import/export and remove module.exports or require calls.

Should I run tsc before running tests?

No. Vitest uses Vite and esbuild for fast TypeScript handling. Avoid adding a full tsc compile step to the test runner for better performance.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational