skills/unit-tests/SKILL.md
Generates well-structured unit tests using Vitest with the "given/should" prose format. Use when writing tests for new code, adding coverage to existing code, or following TDD practices.
npx skillsauth add iulspop/aidd-skills 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.
Act as a top-tier software engineer with serious testing skills.
Write unit tests for: $ARGUMENTS
Each test must answer these 5 questions:
UnitTests {
Constraints {
Use Vitest with describe, expect, and test.
Tests must use the "given: ..., should: ..." prose format.
Colocate tests with functions. Test files should be in the same folder as the implementation file.
Use cuid2 for IDs unless specified otherwise.
If an argument is a database entity, use an existing factory function and override values as needed.
Capture the actual and the expected value in variables.
The top-level describe block should describe the component under test.
The test block should describe the case via "given: ..., should: ...".
Avoid expect.any(Constructor) in assertions. Expect specific values instead.
Always use the toEqual equality assertion.
Empty line before actual variable assignment.
NO empty line between actual and expected assignments.
Empty line after expected variable assignment before the toEqual assertion.
Tests must be readable, isolated, thorough, and explicit.
Test expected edge cases.
Create factory functions for reused data structures rather than sharing mutable fixtures.
}
Boundaries {
React component render tests (.test.tsx) -> use /happy-dom-tests instead
Database or server action tests (.spec.ts) -> use /integration-tests instead
Browser-level user flow tests (.e2e.ts) -> use /e2e-tests instead
This skill is for pure function unit tests (.test.ts) only.
}
}
documentation
Improves text for clarity, directness, and engagement following professional writing best practices. Use when editing documentation, blog posts, product copy, or any text that needs to sound human and avoid LLM patterns.
development
Tailwind CSS patterns for layouts, color schemes, responsive design, and className handling. Use when writing or reviewing component styles.
development
Converts SVG files into optimized React TypeScript components with proper accessibility attributes, currentColor fills, and consistent naming conventions. Use when adding icons or SVG assets to a React project.
development
Security audit for web applications based on OWASP Top 10 and common vulnerabilities. Use when auditing code for security issues, reviewing auth/authz, or before production deployment.