- Home
- Skills
- Shaul1991
- Shaul Agents Plugin
- Backend Tdd
backend-tdd_skill
- Makefile
0
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill shaul1991/shaul-agents-plugin --skill backend-tdd- SKILL.md9.3 KB
Overview
This skill implements Test-Driven Development for Node.js/NestJS backend code. It follows the Red-Green-Refactor cycle to produce small, well-tested increments and integrates Jest, Supertest, and in-memory databases for fast, reliable tests. The agent writes unit, controller, and E2E tests first and then implements the minimal code needed to make them pass.
How this skill works
The agent generates failing tests that express the desired behavior, runs them to confirm failures (RED), implements the smallest amount of code to satisfy the tests (GREEN), and then refactors while keeping tests passing (REFACTOR). It uses repository mocks and test database modules for isolation, and runs E2E tests with Supertest against a Nest application instance. Coverage goals and test commands are included to enforce quality.
When to use it
- When building or extending NestJS services and controllers using TDD.
- When you need reliable unit tests for business logic and controller behavior.
- When validating API flows with automated E2E tests before production deployment.
- When you want strict coverage targets and repeatable test environments.
- When introducing or improving CI test pipelines.
Best practices
- Write clear, behavior-focused test names and cover happy and error paths.
- Use repository mock factories for unit tests and an in-memory or test-container database for integration tests.
- Keep each RED step minimal: tests should fail for the expected reason before implementing code.
- Implement only the code required to pass tests, then refactor for readability and reuse with tests still passing.
- Aim for the coverage targets: service >90%, controller >70%, overall >80%. Run coverage checks in CI.
Example use cases
- Create a UserService: write unit tests for findById and create, mock repository methods, implement minimal logic to pass tests.
- Add a new REST endpoint: write controller E2E tests with Supertest, implement route and DTOs, and iterate until tests pass.
- Hardening error handling: add tests for NotFound and validation errors, implement and refactor consistent exception handling.
- CI integration: run npm test and coverage in pipeline, fail builds that drop below coverage thresholds.
- Database-dependent features: use an in-memory SQLite test module or test containers for E2E validation.
FAQ
Jest is used as the test runner; Supertest is used for E2E HTTP tests; jest.mock and jest.spyOn are used for mocking.
How do I run only E2E tests?
Use the provided script, typically npm run test:e2e, which boots a Nest application and runs Supertest suites.