/vitest:vitest-tdd-workflowfrom vitest
Provides Vitest/NestJS-specific TDD examples and commands for building features, endpoints, or user stories using red-green-refactor. Includes iteration patterns, stub traps, and end-of-iteration checklists.
Ships in vitest. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The cross-language TDD process (cross-layer iterations, RED-GREEN-REFACTOR, working-app-at-each-GREEN, bug-fix workflow, mocks-hiding-bugs) is defined in
craft:tdd-workflow-principles. This skill keeps Vitest/NestJS-specific examples and commands.
See also:
vitest-test-conventionsfor test writing conventions (DAMP, doubles, factories).
"Generate Receipt" feature — each iteration can touch Controller, Domain, and Repository as needed:
Iteration 1: Controller route exists
Test: E2E → authenticated user gets 200
Implement: Empty controller with route
Iteration 2: Eligibility check
Test: E2E → tenant without lease gets 403
Implement: Guard or check in controller
Iteration 3: Domain logic
Test: Unit → receipt calculates correct amount
Implement: Receipt domain model
Iteration 4: Wire it up
Test: E2E → full flow works
Implement: Connect domain to controller
Iteration 5: Edge case
Test: Unit → partial month prorates correctly
Implement: Update calculation logic
// ❌ FORBIDDEN — referencing a non-registered service
@Controller('receipts')
export class ReceiptController {
constructor(private readonly service: ReceiptService) {} // Not registered!
}
// → Test may pass with mocks, but app crashes at runtime
// ✅ CORRECT — register the service
@Module({
providers: [ReceiptService],
})
export class ReceiptModule {}
In addition to the cross-language checklist (see craft:tdd-workflow-principles):
| Check | NestJS action |
|---|---|
| Service injected? | Register in module providers |
| Repository used? | Implement or create a stub, register provider |
| Module imported? | Add to parent module imports |
| Guard added? | Register in module |
// ❌ This test passes but hides a calculation bug
const repo = new InMemoryLeaseRepository([mockLease]);
// ✅ Use real domain objects to catch real problems
const lease = Lease.create(realLeaseData);
const receipt = Receipt.create(lease, period);
Whether a unit earns a test at all is craft:testing-principles' call, not this table's. Once a test is earned, these are the NestJS defaults:
| Code Created | Default level |
|---|---|
| Domain model | Unit test for business logic |
| Controller | E2E test (supertest) for endpoint |
| Repository | Integration test with database |
| Use case | Unit test with in-memory port stubs |
| The access rule a guard enforces | Wherever refusal is observable, usually E2E |
# All tests
pnpm test
# Specific test file
pnpm vitest run src/receipt/receipt.service.spec.ts
# Watch mode
pnpm vitest src/receipt/
# Filter by test name
pnpm vitest run -t "prorated amount"
# Verbose for debugging
pnpm vitest run --reporter=verbose receipt
What SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
Other plugins' skills for the same job
npx claudepluginhub fabiensalles/claude-marketplace --plugin vitest