| name | gen-test |
| description | Generate unit tests for a specified module or function |
| invocation | user |
| user_invocation | /gen-test |
Generate Tests
Generate comprehensive unit tests for the specified module or function. Follow the project's existing test patterns and conventions.
Context
- Test framework: Vitest
- Test file naming:
*.test.ts colocated with source
- Packages:
@yubot/shared, @yubot/backend, @yubot/agent-runtime, @yubot/mobile
- Run tests:
bun run test (all) or bun --filter <package> test (single package)
Steps
- Read the target module/function specified by the user
- Identify the public API, edge cases, and error conditions
- Read 1-2 existing test files to match the project's testing style:
packages/backend/src/server.test.ts — Fastify server.inject() pattern
packages/shared/src/index.test.ts — simple assertion pattern
- Generate tests covering:
- Happy path for each public function/method
- Edge cases (empty input, null, boundary values)
- Error conditions (invalid input, thrown exceptions)
- For agent tools: mock
execute params, verify output shape and side effects
- Write the test file next to the source file (e.g.,
foo.ts → foo.test.ts)
- Run
bun --filter <package> test to verify the new tests pass
Output Format
Write the test file and report:
- Number of test cases generated
- Coverage areas (happy path, edge cases, errors)
- Any tests that need manual review