Skip to content
Agentmart
Submit a tool

typescript-unit-testing

Unit testing for TypeScript/NestJS projects using Jest, @golevelup/ts-jest (DeepMocked/createMock), and in-memory databases, with AAA structure.

Skill by bmad-labs

IndexedMIT★ 18
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/bmad-labs-typescript-unit-testing

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Unit testing for TypeScript/NestJS projects using Jest, @golevelup/ts-jest (DeepMocked/createMock), and in-memory databases, with AAA structure. Use whenever the user is working on `.spec.ts` files or asks to set up Jest, write/add tests for a service/usecase/controller/guard/interceptor/pipe/filter, mock dependencies, review test quality or coverage, run unit tests, debug failing or flaky tests, or optimize test performance and open handles.

Use cases: testing, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/typescript-unit-testing

What's inside

Skill name
typescript-unit-testing
Description
Unit testing for TypeScript/NestJS projects using Jest, @golevelup/ts-jest (DeepMocked/createMock), and in-memory databases, with AAA structure. Use whenever the user is working on `.spec.ts` files or asks to set up Jest, write/add tests for a service/usecase/controller/guard/interceptor/pipe/filter, mock dependencies, review test quality or coverage, run unit tests, debug failing or flaky tests, or optimize test performance and open handles.
License
MIT
Instructions
399 lines in SKILL.md · view on GitHub

Files (81)

  • LICENSE
  • SKILL.md
  • assertions.md · references/common/
  • detect-open-handles.md · references/common/
  • examples.md · references/common/
  • knowledge.md · references/common/
  • performance-optimization.md · references/common/
  • rules.md · references/common/
  • kafka.md · references/kafka/
  • deep-mocked.md · references/mocking/
  • factories.md · references/mocking/
  • jest-native.md · references/mocking/
  • controllers.md · references/nestjs/
  • guards.md · references/nestjs/
  • interceptors.md · references/nestjs/
  • pipes-filters.md · references/nestjs/
  • services.md · references/nestjs/
  • redis.md · references/redis/
  • mongodb.md · references/repository/
  • postgres.md · references/repository/
  • step-01-init.md · workflows/debugging/steps/
  • step-01b-continue.md · workflows/debugging/steps/
  • step-02-classify-failure.md · workflows/debugging/steps/
  • step-03-analyze.md · workflows/debugging/steps/
  • step-04-implement-fix.md · workflows/debugging/steps/
  • step-05-verify-fix.md · workflows/debugging/steps/
  • step-06-document-resolution.md · workflows/debugging/steps/
  • output-template.md · workflows/debugging/templates/
  • workflow.md · workflows/debugging/
  • step-01-init.md · workflows/optimizing/steps/
  • step-01b-continue.md · workflows/optimizing/steps/
  • step-02-identify-opportunities.md · workflows/optimizing/steps/
  • step-03-optimize-setup.md · workflows/optimizing/steps/
  • step-04-fix-open-handles.md · workflows/optimizing/steps/
  • step-05-optimize-async.md · workflows/optimizing/steps/
  • step-06-optimize-data.md · workflows/optimizing/steps/
  • step-07-optimize-organization.md · workflows/optimizing/steps/
  • step-08-measure-improvement.md · workflows/optimizing/steps/
  • step-09-document-optimizations.md · workflows/optimizing/steps/
  • output-template.md · workflows/optimizing/templates/
  • workflow.md · workflows/optimizing/
  • step-01-init.md · workflows/reviewing/steps/
  • step-01b-continue.md · workflows/reviewing/steps/
  • step-02-test-structure.md · workflows/reviewing/steps/
  • step-03-setup-teardown.md · workflows/reviewing/steps/
  • step-04-aaa-pattern.md · workflows/reviewing/steps/
  • step-05-assertions.md · workflows/reviewing/steps/
  • step-06-coverage.md · workflows/reviewing/steps/
  • step-07-exception-testing.md · workflows/reviewing/steps/
  • step-08-compile-report.md · workflows/reviewing/steps/
  • output-template.md · workflows/reviewing/templates/
  • workflow.md · workflows/reviewing/
  • step-01-init.md · workflows/running/steps/
  • step-01b-continue.md · workflows/running/steps/
  • step-02-run-tests.md · workflows/running/steps/
  • step-03-interpret-results.md · workflows/running/steps/
  • step-04-coverage.md · workflows/running/steps/
  • step-05-handle-scenarios.md · workflows/running/steps/
  • step-06-summary-report.md · workflows/running/steps/
  • output-template.md · workflows/running/templates/
  • …and 21 more

SKILL.md (first lines)

# Unit Testing Skill

Unit testing validates individual functions, methods, and classes in isolation by mocking all external dependencies.

---

## Workflows

For guided, step-by-step execution of unit testing tasks, use the appropriate workflow:

| Workflow | Purpose | When to Use |
|----------|---------|-------------|
| [Setup](workflows/setup/workflow.md) | Initialize test infrastructure | New project or missing test setup |
| [Writing](workflows/writing/workflow.md) | Write new unit tests | Creating tests for components |
| [Reviewing](workflows/reviewing/workflow.md) | Review existing tests | Code review, quality audit |
| [Running](workflows/running/workflow.md) | Execute tests | Running tests, analyzing results |
| [Debugging](workflows/debugging/workflow.md) | Fix failing tests | Tests failing, need diagnosis |
| [Optimizing](workflows/optimizing/workflow.md) | Improve test performance | Slow tests, maintainability |

## Workflow Selection Guide

**IMPORTANT**: Before starting any testing task, identify the user's intent and load the appropriate workflow.

### Detect User Intent → Select Workflow

| User Says / Wants | Workflow to Load | File |
|-------------------|------------------|------|
| "Set up tests", "configure Jest", "add testing to project", "install test dependencies" | **Setup** | `workflows/setup/workflow.md` |
| "Write tests", "add tests", "create tests", "test this service/controller" | **Writing** | `workflows/writing/workflow.md` |
| "Review tests", "check test quality", "audit tests", "are these tests good?" | **Reviewing** | `workflows/reviewing/workflow.md` |
| "Run tests", "execute tests", "check if tests pass", "show test results" | **Running** | `workflows/running/workflow.md` |
| "Fix tests", "debug tests", "tests are failing", "why is this test broken?" | **Debugging** | `workflows/debugging/workflow.md` |
| "Speed up tests", "optimize tests", "tests are slow", "fix open handles" | **Optimizing** | `workflows/optimizing/workflow.md` |

### Workflow Execution Protocol

1. **ALWAYS load the workflow file first** - Read the full workflow before taking action
2. **Follow each step in order** - Complete checkpoints before proceeding
3. **Load knowledge files as directed** - Each workflow specifies which `references/` files to read
4. **Verify compliance after completion** - Re-read relevant reference files to ensure quality

---

## Knowledge Base Structure

```
references/
├── common/              # Core testing fundamentals
│   ├── knowledge.md     # Testing philosophy and test pyramid
│   ├── rules.md         # Mandatory testing rules (AAA, naming, coverage)
│   ├── assertions.md    # Assertion patterns and matchers
│   ├── examples.md      # Comprehensive examples by category
│   ├── detect-open-handles.md   # Open handle detection and cleanup
│   └── performance-optimization.md  # Jest runtime optimization
│
├── nestjs/              # NestJS component testing
│   ├── services.md      # Service/usecase testing patterns
│   ├── controllers.md   # Controller testing patterns
│   ├── guards.md        # Guard testing patterns
│   ├── interceptors.md  # Interceptor testing patterns
│   └── pipes-filters.md # Pipe and filter testing
│
├── mocking/             # Mock patterns and strategies
│   ├── deep-mocked.md   # @golevelup/ts-jest patterns
│   ├── jest-native.md   # Jest.fn, spyOn, mock patterns
│   └── factories.md     # Test data factory patterns
│
├── repository/          # Repository testing
│   ├── mongodb.md       # mongodb-memory-server patterns
│   └── postgres.md      # pg-mem patterns
│
├── kafka/               # NestJS Kafka microservices testing
│   └── kafka.md         # ClientKafka, @MessagePattern, @EventPattern handlers
│
└── redis/               # Redis cache testing
    └── redis.md         # Cache operations, health checks, graceful degradation
```

## Quick Reference by Task

### Write Unit Tests
1. **MANDATORY**: Read `references/common/rules.md` - AAA pattern, naming, coverage
2. Read `references/common/assertions.md` - Assertion best practices
3. Read component-specific files:
   - **Services**: `references/nestjs/services.md`
   - **Controllers**: `references/nestjs/controllers.md`
   - **Guards**: `references/nestjs/guards.md`
   - **Interceptors**: `references/nestjs/interceptors.md`
   - **Pipes/Filters**: `references/nestjs/pipes-filters.md`

### Setup Mocking
1. Read `references/mocking/deep-mocked.md` - DeepMocked patterns
2. Read `references/mocking/jest-native.md` - Native Jest patterns
3. Read `references/mocking/factories.md` - Test data factories

### Test Repositories
1. **MongoDB**: `references/repository/mongodb.md`
2. **PostgreSQL**: `references/repository/postgres.md`

### Test Kafka (NestJS Microservices)
- Read `references/kafka/kafka.md` - ClientKafka mocking, @MessagePattern/@EventPattern handlers, emit/send testing

### Test Redis
- Read `references/redis/redis.md` - Cache operations, health checks, graceful degradation

### Examples
- Read `references/common/examples.md` for comprehensive patterns

### Optimize Test Performance
1. Read `references/common/performance-optimization.md` - Worker config, caching, CI optimization
2. Read `references/common/detect-open-handles.md` - Fix open handles preventing clean exit

### Debug Open Handles
- Read `references/common/detect-open-handles.md` - Detection commands, common handle types, cleanup patterns

---

## Core Principles

From bmad-labs/skills, MIT.

More from bmad-labs/skills

Signals

Stars
18
Forks
4
Open issues
0
Last commit (this folder)
May 7, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from bmad-labs

Cite this page

typescript-unit-testing skill. Agent Mart. https://agentmart.dev/skills/bmad-labs-typescript-unit-testing (last updated 2026-10-24)