nest-testing

Build NestJS test suites with mocked and real dependency injection.

9|1|Updated Jun 16, 2026
One-click install
npx skills add https://github.com/AratKruglik/antigravity-sdlc --skill nest-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nest-testing
Source: https://github.com/AratKruglik/antigravity-sdlc/tree/main/plugins/nestjs-plugin/skills/nest-testing
Command: npx skills add https://github.com/AratKruglik/antigravity-sdlc --skill nest-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

NestJS testing patterns that help you validate services, controllers, and their dependencies with mocked and real DI setups.

Core Features & Use Cases

  • Unit testing with mocked providers to verify individual services.
  • Integration testing with real DI and mocked external services to validate component interactions.
  • E2E testing of HTTP endpoints using Nest's TestingModule and end-to-end tooling.

Quick Start

Run the project test suite to validate service behavior and API contracts.

Frequently Asked Questions about nest-testing

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

FAQPage Schema
How do I set up a NestJS testing module with mocked providers for unit tests?

NestJS unit testing uses a synthetic IoC container built via TestingModule to override dependencies with mocks. You configure the TestingModule to replace real services with custom providers, isolating controllers and services for focused validation using Jest or Vitest.

What is the best way to mock Prisma and Mongoose dependencies in a NestJS test suite?

Mocking Prisma and Mongoose in NestJS testing involves overriding database providers using getRepositoryToken. You inject mocked repository objects into the TestingModule to simulate database interactions without hitting real external data stores.

Does NestJS testing work with both Jest and Vitest for E2E HTTP endpoint validation?

Yes, NestJS end-to-end testing supports both Jest and Vitest. E2E tests initialize the full Nest application via TestingModule to exercise real HTTP endpoints and validate API contracts across the entire request-response cycle.

What is the difference between integration testing and unit testing in NestJS?

NestJS unit testing isolates individual services with fully mocked dependencies, while integration testing uses real dependency injection with only external services mocked. Integration tests validate how multiple components interact within the actual IoC container.

When do I need to override dependencies in a NestJS testing module?

You override dependencies in NestJS testing when you need to isolate components for unit tests or simulate external service behaviors during integration tests. This ensures deterministic test outcomes by controlling injected provider logic.

Why are my mocked repository tokens not resolving correctly in NestJS tests?

Mocked repository tokens in NestJS tests fail when getRepositoryToken is not used correctly to match the entity interface. Ensure your TestingModule overrides the exact token generated by NestJS for the specific repository provider.