.cursor/skills/unit-test/SKILL.md
Write Vitest unit tests following project conventions with proper stubs and assertions.
npx skillsauth add carrot-foundation/methodology-rules Write Unit TestsInstall 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.
File naming: Use *.spec.ts for unit tests and *.e2e.spec.ts for end-to-end tests. Place test files alongside the source file they test.
Test framework: Use Vitest. Test environment variables are loaded from .env-files/.env.test.
Test data generation:
@faker-js/faker for random synthetic data (names, dates, numbers)zocker with createStubFromSchema() for generating data from Zod schemas@carrot-fndn/shared/testing: stubRuleInput(), stubDocument(), createStubFromSchema()Test structure:
describe blocks to group related testsit.each for table-driven tests when testing multiple similar scenariosexpect.objectContaining() for partial assertions on objectsshould languageRule processor tests: Follow the standard pattern:
{rule-name}/
├── {rule-name}.processor.spec.ts # Unit tests for evaluateResult()
├── {rule-name}.lambda.e2e.spec.ts # E2E tests for the Lambda handler
└── {rule-name}.test-cases.ts # Shared test data and fixtures
Assertions:
evaluateResult() returns the expected RuleOutputRun and verify: Execute pnpm nx test <project-name> to run tests for the specific project. Ensure all tests pass before finishing.
databases
Create and modify Zod schemas for runtime validation with proper type inference.
tools
Autonomously implement a task following project conventions with iterative verification.
testing
Analyze a pull request diff and provide structured feedback on correctness, conventions, and quality.
testing
Run quality gates, commit changes, push branch, and create a pull request.