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.tscolocated with source - •Packages:
@yubot/shared,@yubot/backend,@yubot/agent-runtime,@yubot/mobile - •Run tests:
bun run test(all) orbun --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— Fastifyserver.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
executeparams, 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> testto 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