typescript-unit-testing

Write and debug deterministic Jest unit tests for TypeScript and NestJS.

Updated May 17, 2026
One-click install
npx skills add https://github.com/thuantan2060/facebook-sale-tracking --skill typescript-unit-testing-thuantan2060
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-unit-testing
Source: https://github.com/thuantan2060/facebook-sale-tracking/tree/main/.agents/skills/typescript-unit-testing
Command: npx skills add https://github.com/thuantan2060/facebook-sale-tracking --skill typescript-unit-testing-thuantan2060

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves the problem of flaky or failing unit tests in TypeScript/NestJS by providing a structured, high-quality approach to setting up Jest, writing deterministic tests, diagnosing failures, and improving reliability and performance.

Core Features & Use Cases

  • Jest unit testing workflows: Setup, writing, reviewing, running, debugging, and optimizing tests using dedicated workflow files.
  • Deterministic NestJS testing conventions: Enforces Arrange-Act-Assert (AAA), consistent naming, and deep mocking via DeepMocked/createMock.
  • Reliability guardrails: Detects and fixes open handles, prevents async hangs, and reduces noisy outputs by redirecting test logs to temp files.
  • Target-specific guidance: Includes patterns for services/usecases, controllers, guards, interceptors, pipes/filters, plus mocking strategies and repository/Redis/Kafka test approaches as references.

Quick Start

Use the typescript-unit-testing Skill whenever you are working on a Jest-based unit test for a NestJS/TypeScript component, such as when creating a new .spec.ts file or debugging failing tests.

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 deterministic Jest unit tests for NestJS providers?

Write deterministic Jest unit tests for NestJS using DeepMocked mocks and the Arrange-Act-Assert structure to isolate behavior validation for services, usecases, controllers, guards, and interceptors.

What is the best way to fix open handles and async timeouts in Jest?

Fix open handles and async timeouts in Jest by following provided step-based debugging workflows, redirecting noisy test logs to temp files, and verifying mock calls to isolate hanging behavior one test at a time.

How do I mock repository and Redis dependencies in NestJS tests?

Mock repository, Redis, and Kafka dependencies in NestJS tests by utilizing deep mocking strategies via createMock, and use in-memory databases for repository tests to ensure isolated and deterministic behavior validation.

Does this Skill support testing NestJS guards, interceptors, pipes, and filters?

Yes, this Skill provides target-specific guidance and testing patterns for NestJS guards, interceptors, pipes, and filters, ensuring isolated behavior validation using deep mocks and consistent AAA naming conventions.

Why are my TypeScript unit tests flaky and how can I improve their performance?

Flaky TypeScript tests are improved by applying reliability guardrails that detect open handles, prevent async hangs, reduce noisy outputs via temp-file capture, and optimize Jest test performance through structured debugging workflows.