Skip to content
Back to skills

Testing

ASecurity

Unit and E2E testing strategies with Docker.

  • 8 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
ai-agentstypescriptdockertestingdatabasesecurity

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add ngxtm/devkit --skill testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ngxtm-testing-devkit/badge)](https://www.skillsdirectory.com/skills/ngxtm-testing-devkit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: NestJS Testing
description: Unit and E2E testing strategies with Docker.
metadata:
  labels: [nestjs, testing, jest, e2e]
  triggers:
    files: ['**/*.spec.ts', 'test/**']
    keywords: [Test.createTestingModule, supertest, jest]
---

# NestJS Testing Standards

## Strategy

1. **Unit Tests**: Isolated logic (Services). Mock **all** dependencies (`jest.fn()`).
2. **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 `TRUNCATE` in `afterEach` to 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

```typescript
// Standard Setup
const module: TestingModule = await Test.createTestingModule({
  providers: [
    UsersService,
    { provide: getRepositoryToken(User), useValue: mockRepo },
  ],
}).compile();
```

Files in this skill

  • SKILL.md1.3 KB
  • references/REFERENCE.md425 B
  • references/unit-testing.md4.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…