caliber-testing
Writes Vitest tests following project patterns: __tests__/ directories, vi.mock() for module mocking with vi.hoisted() for test-time factories, global LLM mock from src/test/setup.ts, environment variable save/restore in beforeEach/afterEach, vi.clearAllMocks() lifecycle, and test file organization. Use when user says 'write tests', 'add test coverage', 'test this', creates *.test.ts files, or when test failures appear in CI. Do NOT use for non-test code or for debugging without writing tests.
npx skills add caliber-ai-org/ai-setup --skill caliber-testing --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Caliber Testing ## Critical - All test files MUST be placed in `__tests__/` directories parallel to source files: `src/[module]/__tests__/[module].test.ts` - Register any new `__tests__/` directories in `vitest.config.ts`'s `include` glob (already configured: `src/**/*.test.ts`) - NEVER mock `src/test/setup.ts` — it is the global LLM provider mock already applied to all tests - Environment variable tests MUST save `process.env` in `beforeEach`, restore in `afterEach`, and explicitly delete env vars to test absence - Temporary file/directory cleanup MUST happen in `afterEach`, not in individual test cleanup. Use `fs.rmSync(dir, { recursive: true, force: true })` - When a test requires unmocking modules mocked in global setup, call `vi.unmock('../module.js')` BEFORE the import statement - Run `pnpm test` locally and `pnpm test:coverage` before committing to verify coverage thresholds (lines: 50, functions: 50, branches: 50, statements: 50) ## Instructions ### Step 1: Create the test file in the correct directory 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 th
- Critical
- Instructions
- Step 1: Create the test file in the correct directory
- Step 2: Import test framework
- Step 3: Set up module mocking (if needed)
- Step 4: Organize tests in describe blocks
- Step 5: Manage environment and process state
- Step 6: Manage temporary files and directories
- Step 7: Handle mock state cleanup
- Step 8: Test assertions
- Step 9: Run tests
- Examples
- Example 1: Testing a module with environment variables (config.test.ts pattern)
- Common Issues
pnpm test # Run all tests in watch mode pnpm test:coverage # Check coverage thresholds pnpm test -- src/my/path/__tests__/my.test.ts # Run single test file
What does the caliber-testing skill do?
Writes Vitest tests following project patterns: __tests__/ directories, vi.mock() for module mocking with vi.hoisted() for test-time factories, global LLM mock from src/test/setup.ts, environment variable save/restore in beforeEach/afterEach, vi.clearAllMocks() lifecycle, and test file organization. Use when user says 'write tests', 'add test coverage', 'test this', creates *.test.ts files, or when test failures appear in CI. Do NOT use for non-test code or for debugging without writing tests.
How do I install it?
Run `npx skills add caliber-ai-org/ai-setup --skill caliber-testing --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From caliber-ai-org/ai-setup, a repository with 1,235 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
