backend-test
Generate unit, integration, and mock-based tests for backend code that already exists.
Triggers
Natural-language phrases that auto-invoke the skill:
- “write test for [file/function]”
- “add test” / “add tests”
- “test this”
- “create test for [thing]”
- “test the [api/service/function]“
What it does
- Queries the knowledge graph for testing patterns and known flaky-test pitfalls (Phase 0)
- Locates the code under test and reads it in full so tests cover actual, not assumed, behavior
- Detects the test framework (Jest, Vitest, Mocha, or the built-in node:test runner) and mirrors existing test conventions
- Generates tests covering the happy path, error cases, and at least one edge case
- Uses the supertest pattern for API/integration tests and mocks to isolate the unit
- Runs the generated tests, fixing the tests (not the source) when they assume wrong behavior — and surfacing real source bugs instead of hiding them
- Emits an execution summary into the knowledge graph
Example
"write tests for src/services/userService.ts"Produces a test file placed where the project keeps its tests, covering valid input, error handling, and edge cases, verified to pass on first run.
Related
- backend-endpoint — generates tests as part of creating a new endpoint; use backend-test for existing code
- Knowledge Graph — where testing patterns and pitfalls are surfaced from