sdcorejs-testing-integration-nestjs

Generate NestJS integration tests with real DI wiring and pg-mem database queries.

2|Updated Apr 18, 2026
One-click install
npx skills add https://github.com/sdcorejs/sdcorejs-agent --skill sdcorejs-testing-integration-nestjs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sdcorejs-testing-integration-nestjs
Source: https://github.com/sdcorejs/sdcorejs-agent/tree/main/plugin/skills/sdcorejs-testing-integration-nestjs
Command: npx skills add https://github.com/sdcorejs/sdcorejs-agent --skill sdcorejs-testing-integration-nestjs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Removes flaky, incomplete testing by validating NestJS service and repository logic with real TypeORM wiring and real SQL execution paths (without the HTTP server).

Core Features & Use Cases

  • Integration coverage without HTTP: Exercises Test.createTestingModule DI container wiring plus repository + service behavior while skipping the HTTP layer.
  • Fast DB realism with pg-mem: Runs against an in-memory Postgres (pg-mem) to validate queries, transactions, and constraints using a real DataSource.
  • Boundary mocking at integration points: Mocks external APIs at the provider boundary (not at the HTTP-client level) to keep tests deterministic.
  • Typical use cases: transaction semantics rollback checks, query correctness, business-logic error paths like ConflictException and NotFoundException, and permission/guard verification.

Quick Start

Use sdcorejs-testing-integration-nestjs to generate an integration spec that boots a real Nest testing module and a pg-mem TypeORM DataSource, seeds minimal lookup data, and asserts both happy-path and error-path behavior against the database state.

Frequently Asked Questions about sdcorejs-testing-integration-nestjs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write NestJS integration tests with real dependency injection and database queries?

NestJS integration tests with real dependency injection use `Test.createTestingModule` to wire actual providers and a pg-mem TypeORM DataSource to execute real database queries, validating service logic without the HTTP layer.

How does pg-mem work with TypeORM for transaction rollback testing in NestJS?

pg-mem provides an in-memory Postgres database for TypeORM, enabling fast transaction rollback testing by validating real SQL constraints and multi-write rollback semantics against a real DataSource without persistent state.

What is the best way to test NestJS repository logic and error behavior without mocking the database?

Testing NestJS repository logic without mocks requires booting a real DI container alongside a pg-mem DataSource, allowing you to assert observable database outcomes and error paths like ConflictException or NotFoundException directly.

Can I use pg-mem to test NestJS service business logic and permission guards without starting the HTTP server?

Yes, you can test NestJS service business logic and permission guards without the HTTP server by using `Test.createTestingModule` to bootstrap real DI wiring and asserting behavior against a pg-mem TypeORM DataSource.

How do I isolate NestJS integration tests when using a shared in-memory database?

You isolate NestJS integration tests using minimal per-test seeding and teardown routines, ensuring each test validates its database state independently without cross-test contamination from the shared pg-mem DataSource.

Why should I mock external APIs at the provider boundary instead of the HTTP-client level in integration tests?

Mocking external APIs at the provider boundary in integration tests keeps the internal NestJS DI wiring and TypeORM repository execution paths real, ensuring deterministic tests that validate actual business workflow logic.