agents/skills/vitest-testing/SKILL.md
Write or review Vitest tests with clear behaviour-focused assertions, appropriate globals/imports, file snapshots for terminal output, and readable fixture setup. Use when adding tests, fixing Vitest failures, or improving TypeScript test quality.
npx skillsauth add ryoppippi/dotfiles vitest-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use the tdd skill when the task is a logic change or bug fix that should start with a failing test. This skill covers Vitest-specific test shape and review rules.
vitest.config.* before assuming globals are enabled.describe, it, expect, vi, beforeEach, and assert directly without importing them.await import() and other dynamic imports in tests unless the behaviour under test is dynamic loading.vi.stubEnv() instead of mutating process.env directly.it.try/catch for expected failures. Use expect(...).toThrow(), await expect(...).rejects, or explicit Result failure assertions.if branches inside test bodies. Split behaviours into separate tests or use it.each for table-driven cases.assert to make preconditions explicit and narrow nullable values instead of using non-null assertions.toMatchFileSnapshot for human-readable CLI/table output so layout changes are reviewable.Expected failure:
it('rejects invalid config', async () => {
await expect(loadConfig('bad.json')).rejects.toThrow(Error);
});
Table-driven case:
it.each([
['daily', '2026-05-16'],
['monthly', '2026-05'],
])('groups %s rows by period', (reportType, expectedPeriod) => {
const rows = groupUsage(reportType, usage);
expect(rows[0]?.period).toBe(expectedPeriod);
});
Narrowing with assert:
it('returns the first row', () => {
const rows = getRows();
const firstRow = rows[0];
assert.isDefined(firstRow, 'expected at least one row');
expect(firstRow.id).toBe('row-1');
});
development
Prevents and handles GitHub API rate limits during Nix commands. Use when running nix flake, nix run, nix build, nix shell, or comma against GitHub-backed inputs.
tools
Resolves missing CLI tools. Use when a command is unavailable, a shell reports command not found, or a tool must be run without installing it globally.
development
Guides t-wada Red-Green-Refactor TDD. Use when implementing features, fixing bugs, or refactoring logic with strict test-first development.
documentation
Guides agent-skill creation and updates following Anthropic's SKILL.md best practices. Use when adding or editing skills under `agents/skills/`, writing SKILL.md frontmatter, references, or skill routing.