knofler/a_thousand_lamps/unit-test-write
Claude Code and agent skill by knofler/a_thousand_lamps
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Write unit tests for functions and modules — cover happy path, edge cases, and error cases with proper mocking and assertions. Triggers: unit test, write test, test function, test module, jest test, vitest
Install
npx vskill@latest install knofler/a_thousand_lamps/unit-test-writeSKILL.md
The same SKILL.md was published earlier as knofler/myai/unit-test-write.
Unit Test Write
Write thorough unit tests for a given function or module.
Tech Stack
Jest or Vitest | vi.mock() / jest.mock() | built-in expect API
Playbook
1. Identify the function or module to test
- Read the source file and understand inputs, outputs, and side effects.
- List all public exports that need coverage.
- Identify dependencies that must be mocked.
2. Create the test file
- Place
<module>.test.tsalongside<module>.ts(or intests/unit/). - Import the module under test and any test utilities.
3. Structure with describe/it blocks
4. Cover happy path
- Test the primary use case with typical valid inputs.
- Assert return value and verify expected side effects.
5. Cover edge cases
- Empty inputs (empty string, empty array, null, undefined).
- Boundary values (0, negative numbers, max integers).
- Special characters, Unicode, and large inputs.
6. Cover error cases
- Invalid argument types or shapes.
- Missing required parameters.
- Network/IO failures (mock rejections).
- Verify error messages and error types.
7. Mock dependencies
- Mock external modules with
vi.mock()orjest.mock(). - Use
vi.fn()/jest.fn()for spies. Reset inbeforeEach. - Prefer dependency injection over global mocks when possible.
8. Assert expected behavior
- Use specific matchers:
toBe,toEqual,toContain,toThrow. - Verify mock calls with
toHaveBeenCalledWith. - For async code, always
awaitand useresolves/rejects.
9. Run and verify
- Run:
npx vitest run <file>. Check coverage:--coverage.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingAI/skills/unit-test-write/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/knofler/a_thousand_lamps/unit-test-write)