sdcorejs-testing-e2e-nestjs

Write NestJS endpoint E2E tests with supertest and PostgreSQL.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ensures NestJS endpoints work correctly end-to-end with real validation, authz/authn, transaction behavior, and database semantics that unit tests often miss.

Core Features & Use Cases

  • Real DB-backed E2E runs: boot the full NestJS app and execute requests with supertest against PostgreSQL using testcontainers (preferred) or pg-mem.
  • Auth + permission flow coverage: validate AuthGuard + HasPermission using an auth fixture and assert 401/403 outcomes per endpoint.
  • Bilingual error shape verification: assert { vi, en } error message payloads for ZodValidationGuard-driven failures (e.g., 422) and confirm domain errors like 409 duplicates.
  • Transaction rollback assertions: prove multi-table write endpoints roll back when a step fails by checking observable state after an induced error.

Quick Start

Run the E2E suite after wiring the endpoint by executing the skill’s guidance for test/setup-e2e.ts and test/jest-e2e.config.js, then invoke npm run test:e2e.

Frequently Asked Questions about sdcorejs-testing-e2e-nestjs

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

FAQPage Schema
How do I write NestJS E2E tests with a real PostgreSQL database?

Write NestJS E2E tests by booting the full app with @nestjs/testing and executing requests via supertest against a real PostgreSQL database provisioned through testcontainers or pg-mem. This approach validates actual database semantics, transaction rollbacks, and endpoint behavior that unit tests miss.

How does transaction rollback verification work in NestJS end-to-end tests?

Transaction rollback verification in NestJS E2E tests works by inducing a failure during a multi-table write operation and asserting that observable database state returns to its pre-request condition. It uses supertest to trigger the endpoint and checks the PostgreSQL database to confirm no partial writes persisted.

Can I use testcontainers with supertest to test NestJS auth and permission flows?

Yes, you can use testcontainers with supertest to test NestJS auth and permission flows by applying an auth fixture to validate AuthGuard and HasPermission decorators against a real PostgreSQL database. This setup accurately asserts 401 unauthorized and 403 forbidden outcomes per endpoint.

What is the best way to assert bilingual error messages in NestJS API responses?

The best way to assert bilingual error messages in NestJS API responses is to validate the { vi, en } error payload shape returned by ZodValidationGuard-driven failures. Use supertest to trigger 422 unprocessable entity or 409 duplicate domain errors and assert both language fields are present.

Why do my NestJS E2E tests fail when running concurrently with testcontainers?

NestJS E2E tests fail when running concurrently with testcontainers due to shared PostgreSQL database state conflicts. Ensure reliable E2e execution by using the Jest --runInBand reliability guardrail in your jest-e2e config to serialize test runs and prevent parallel database interference.