Agent skill
NestJS Testing
Unit and E2E testing strategies with Docker.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/testing-hoangnguyen0403-agent-skills-standar-6
Metadata
Additional technical details for this skill
- labels
-
nestjs testing jest e2e
- triggers
-
{ "files": [ "**/*.spec.ts", "test/**" ], "keywords": [ "Test.createTestingModule", "supertest", "jest" ] }
SKILL.md
NestJS Testing Standards
Priority: P2 (MAINTENANCE)
Unit testing, integration testing, and E2E testing patterns for NestJS applications.
- Unit Tests: Isolated logic (Services). Mock all dependencies (
jest.fn()). - E2E Tests: Full lifecycle (
test/app.e2e-spec.ts).- Rule: Use a real Test Database (Docker). Never mock the database in E2E.
- Idempotency: Mandatory cleanup. Use a transaction rollback strategy or explicit
TRUNCATEinafterEachto ensure tests don't leak state.
E2E Best Practices (Pro)
- Overriding: Use
.overrideProvider(AuthGuard).useValue({ canActivate: () => true })to bypass security in functional flow tests. - Factories: Use Factory patterns (e.g.
mockUserFactory()) to generate DTOs/Entities. Avoid hardcoded JSON literals.
Tools
- Runner: Jest (swc/ts-jest).
- Mocks:
jest.fn(),jest.spyOn().
Setup Pattern
// Standard Setup
const module: TestingModule = await Test.createTestingModule({
providers: [
UsersService,
{ provide: getRepositoryToken(User), useValue: mockRepo },
],
}).compile();
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?