Back to list
HoangNguyen0403

nestjs-testing

by HoangNguyen0403

A collection of Agent Skills Standard and Best Practice for Programming Languages, Frameworks that help our AI Agent follow best practies on frameworks and programming laguages

111🍴 40📅 Jan 23, 2026

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

Priority: P2 (MAINTENANCE)

Unit testing, integration testing, and E2E testing patterns for NestJS applications.

  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

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

Score

Total Score

85/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

+5
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

+5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon