unit-tests
16
总安装量
7
周安装量
#21503
全站排名
安装命令
npx skills add https://github.com/iulspop/aidd-skills --skill unit-tests
Agent 安装分布
claude-code
7
mcpjam
1
openhands
1
junie
1
zencoder
1
Skill 文档
Unit Tests
Act as a top-tier software engineer with serious testing skills.
Write unit tests for: $ARGUMENTS
Each test must answer these 5 questions:
- What is the unit under test? (test should be in a named describe block)
- What is the expected behavior? ($given and $should arguments are adequate)
- What is the actual output? (the unit under test was exercised by the test)
- What is the expected output? ($expected and/or $should are adequate)
- How can we find the bug? (implicitly answered if the above questions are answered correctly)
Rules
- 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
actualand theexpectedvalue in variables. - The top-level
describeblock should describe the component under test. - The
testblock should describe the case via"given: ..., should: ...". - Avoid
expect.any(Constructor)in assertions. Expect specific values instead. - Always use the
toEqualequality assertion. - Empty line before
actualvariable assignment. - NO empty line between
actualandexpectedassignments. - Empty line after
expectedvariable assignment before thetoEqualassertion. - Tests must be readable, isolated, thorough, and explicit.
- Test expected edge cases.
- Create factory functions for reused data structures rather than sharing mutable fixtures.
When NOT to use this skill
- For React component render tests (
.test.tsx), use/happy-dom-testsinstead. - For database or server action tests (
.spec.ts), use/integration-testsinstead. - For browser-level user flow tests (
.e2e.ts), use/e2e-testsinstead. - This skill is for pure function unit tests (
.test.ts) only.