typescript-unit-testing

Write and review Jest unit tests for TypeScript and NestJS applications.

14|3|Updated Jan 15, 2026
One-click install
npx skills add https://github.com/bmad-labs/skills --skill typescript-unit-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-unit-testing
Source: https://github.com/bmad-labs/skills/tree/main/skills/typescript-unit-testing
Command: npx skills add https://github.com/bmad-labs/skills --skill typescript-unit-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide and practical examples for writing high-quality unit tests for TypeScript/NestJS projects using Jest. It covers everything from basic setup to advanced debugging and optimization techniques, ensuring your code is robust and maintainable.

Core Features & Use Cases

  • Test Structure & Conventions: Follows AAA pattern, uses target for SUT, and DeepMocked for type-safe mocks.
  • Component-Specific Guidance: Provides tailored advice for testing services, controllers, guards, pipes, and repositories.
  • Debugging & Optimization: Offers systematic approaches to fix failing tests and improve test suite performance.
  • Use Case: A developer needs to write unit tests for a new NestJS service. They can use this Skill to generate the test file structure, plan test cases (happy path, edge cases, errors), implement the tests following best practices, and ensure mock interactions are correctly verified.

Quick Start

Use the typescript-unit-testing skill to write tests for the UserService class.

Frequently Asked Questions about typescript-unit-testing

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

FAQPage Schema
How do I write unit tests for a NestJS service using Jest?

To write unit tests for a NestJS service using Jest, structure your tests using the AAA pattern, define the System Under Test as the target, and use DeepMocked for type-safe mocks to verify component interactions.

What is the best way to mock dependencies in TypeScript unit tests?

The best way to mock dependencies in TypeScript unit tests is using @golevelup/ts-jest to generate DeepMocked type-safe mocks, ensuring robust and maintainable interactions across services, controllers, and repositories.

Why does my Jest test suite have open handles and performance issues?

Jest test suite open handles and performance issues occur when asynchronous operations are not properly closed, requiring systematic debugging approaches and performance optimization techniques to detect open handles and improve execution speed.

How do I test NestJS controllers, guards, and pipes effectively?

To test NestJS controllers, guards, and pipes effectively, follow component-specific guidance to plan test cases for happy paths, edge cases, and errors, ensuring mock interactions and assertions follow best practices.

Can I use the AAA pattern to improve test coverage in TypeScript?

Yes, you can use the AAA pattern to improve test coverage in TypeScript by structuring tests into Arrange, Act, and Assert phases, ensuring systematic validation of services, controllers, and repositories.