
Vitest
Bootstrap Vitest in an existing repo with the right config, setup files, sample test, and scripts for Workers, React, Node, or libraries.
Overview
Vitest is an agent skill most often used in Ship (also Build) that detects your project shape and generates Vitest config, setup, utilities, and a sample test—including Jest migration paths.
Install
npx skills add https://github.com/jezweb/claude-skills --skill vitestWhat is this skill?
- Four-step workflow: detect project type, configure, scaffold, wire package.json and TypeScript
- Classifies Cloudflare Workers, React, Node, and library projects from package.json and wrangler.toml
- Generates vitest.config.ts, test setup, utilities, and a working sample test
- Covers mocking patterns, coverage config, workspace setup, and Jest migration
- Extends existing vite.config.ts instead of replacing it when Vite is already present
- Four-step workflow: detect, configure, scaffold, wire up
Adoption & trust: 1.1k installs on skills.sh; 841 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need automated tests in a Vite or Workers repo but lack vitest.config.ts, setup, and scripts that match your runtime environment.
Who is it for?
Solo builders on TypeScript Vite, React, Node, or Cloudflare Workers projects starting or fixing Vitest from zero.
Skip if: Teams that require Playwright-only E2E with no unit layer, or pure Python/Rust repos with no Node test runner plan.
When should I use this skill?
User mentions adding tests, setting up Vitest, configuring tests, migrating from Jest, fixing testing infrastructure, or asks how to test this.
What do I get? / Deliverables
You get committed config, scaffolded tests, and package.json scripts so you can run Vitest locally and in CI on the next ship iteration.
- vitest.config.ts
- Test setup and utilities
- Sample test and package.json scripts
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Testing infrastructure is canonically shelved under Ship because it gates safe releases, even though much scaffolding happens while still in Build. Testing subphase matches file-generating setup, mocking, coverage, workspace, and Jest migration—not one-off debug fixes.
Where it fits
Scaffold Vitest beside a React Vite app while implementing UI components.
Add unit tests for Node API handlers before integrating new routes.
Generate vitest.config and CI scripts before merging a release branch.
Lock coverage thresholds ahead of a public launch checklist.
How it compares
A file-generating setup skill—not a Vitest API cheat sheet or an MCP test runner integration.
Common Questions / FAQ
Who is vitest for?
Indie and solo developers using jezweb-style Claude skills who want Vitest wired to their actual project type without hand-copying configs from blog posts.
When should I use vitest?
Use it in Build while adding test coverage to new features, and in Ship when configuring CI, migrating from Jest, or repairing broken vitest.config and setup files.
Is vitest safe to install?
It writes config and test files in your repo—review the Security Audits panel on this Prism page and inspect generated scripts before running in CI.
SKILL.md
READMESKILL.md - Vitest
# Vitest Setup Detect the project type, generate the right Vitest configuration, and produce working test infrastructure. Not a reference card — this skill creates files. ## Workflow 1. **Detect** — scan the project to determine type and existing setup 2. **Configure** — generate vitest.config.ts tailored to the environment 3. **Scaffold** — create test setup, utilities, and a sample test 4. **Wire up** — add package.json scripts and TypeScript config ## Step 1: Detect Project Type Read these files to determine the project: ``` package.json → dependencies, scripts, type field tsconfig.json → paths, compiler options wrangler.toml → Cloudflare Workers project vite.config.ts → existing Vite setup (extend, don't replace) vitest.config.ts → already configured? just fill gaps jest.config.* → migration candidate src/ → source structure ``` Classify as one of: | Type | Signals | Environment | |------|---------|-------------| | **Cloudflare Workers** | wrangler.toml, @cloudflare/workers-types, cloudflare vite plugin | `node` with Workers-specific setup | | **React (Vite)** | @vitejs/plugin-react, react-dom | `jsdom` or `happy-dom` | | **React (SSR/TanStack Start)** | @tanstack/start, vinxi | Split: `node` for server, `jsdom` for client | | **Node/Hono API** | hono, express, no react-dom | `node` | | **Library** | exports field, no framework deps | `node` | If a `vite.config.ts` already exists, extend it rather than creating a separate vitest.config.ts — Vitest reads Vite config natively. ## Step 2: Install Dependencies Generate the install command based on detected type: ```bash # Base (always) pnpm add -D vitest # React projects — add jsdom and Testing Library pnpm add -D @vitest/coverage-v8 jsdom @testing-library/react @testing-library/jest-dom @testing-library/user-event # Workers projects — add Cloudflare test utilities pnpm add -D @vitest/coverage-v8 @cloudflare/vitest-pool-workers # Node/Hono projects pnpm add -D @vitest/coverage-v8 # If migrating from Jest, also remove: pnpm remove jest ts-jest @types/jest jest-environment-jsdom babel-jest ``` Use the project's package manager (check for pnpm-lock.yaml, yarn.lock, bun.lockb, or package-lock.json). ## Step 3: Generate vitest.config.ts ### Cloudflare Workers ```typescript import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config"; export default defineWorkersConfig({ test: { globals: true, poolOptions: { workers: { wrangler: { configPath: "./wrangler.toml" }, }, }, }, }); ``` If the project uses the Cloudflare Vite plugin (`@cloudflare/vite-plugin`), integrate into the existing vite.config.ts instead: ```typescript /// <reference types="vitest/config" /> import { defineConfig } from "vite"; import { cloudflare } from "@cloudflare/vite-plugin"; export default defineConfig({ plugins: [cloudflare()], test: { globals: true, }, }); ``` ### React (Vite) ```typescript /// <reference types="vitest/config" /> import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; export default defineConfig({ plugins: [react()], test: { globals: true, environment: "jsdom", setupFiles: ["./src/test/setup.ts"], css: true, }, }); ``` If a vite.config.ts already exists, add the `test` block to it rather than creating a new file. ### Node / Hono API ```typescript import { defineConfig } from "vitest/config"; export default defineConfig({ test: { globals: true