Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Writes Vitest tests for TypeScript projects using __tests__ directories, vi.mock(), global LLM mocks, and env var save/restore.
Use this skill ↓32% 91%+59 ptsof test cases passed
Passed 20 of 22 test cases with the skill, and 7 of 22 without it.
3 of 3 safety checks passed
12 agent runs
__tests__/ directories parallel to source files: src/[module]/__tests__/[module].test.ts__tests__/ directories in vitest.config.ts's include glob (already configured: src/**/*.test.ts)src/test/setup.ts — it is the global LLM provider mock already applied to all testsprocess.env in beforeEach, restore in afterEach, and explicitly delete env vars to test absenceafterEach, not in individual test cleanup. Use fs.rmSync(dir, { recursive: true, force: true })vi.unmock('../module.js') BEFORE the import statementpnpm test locally and pnpm test:coverage before committing to verify coverage thresholds (lines: 50, functions: 50, branches: 50, statements: 50)Create src/[module]/__tests__/[module].test.ts. The parent source file is src/[module]/[module].ts.
Verify: The __tests__ directory exists at the same level as the source file being tested.
At the top of every test file, import from vitest:
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
Add additional imports based on what you're testing:
import fs from 'fs'; import path from 'path'; import os from 'os';fs.mkdtempSync(path.join(os.tmpdir(), 'caliber-prefix-'))import { execSync } from 'child_process';Verify: All required test utilities are imported before test definitions.
If testing a module that imports other modules you want to mock:
vi.mock('../config.js', () => ({
loadConfig: vi.fn(),
writeConfigFile: vi.fn(),
}));
Next to this one in the catalogue, plus more from the same author.