All skills
bmad-labs avatar

/typescript-e2e-testing

@3bcc7a6
by bmad-labsbmad-labs/skills15 stars
4

E2E and integration testing for TypeScript/NestJS projects using Jest, supertest, and real infrastructure via Docker (Kafka, PostgreSQL, MongoDB, Redis) with the Given-When-Then pattern. Use whenever the user is working on `.e2e-spec.ts` files or anything under `test/e2e/`, or asks to set up, write, review, run, debug, or optimize E2E or integration tests — including flaky tests, docker-compose for tests, Kafka/Redpanda consumers, test isolation, or GWT compliance.

Use this Skill: https://skilld.dev/gh/bmad-labs/skills/typescript-e2e-testing

This session only. Nothing lands on disk.

referencescommonknowledge.md

≈705 tokens on demand. Your agent reads this file only when SKILL.md points to it.

E2E Testing Core Knowledge

What is E2E Testing?

End-to-End (E2E) testing validates the complete flow of an application from the user's perspective, testing the integration of all components including databases, message brokers, and external services.

E2E vs Unit vs Integration Testing

Aspect Unit Tests Integration Tests E2E Tests
Scope Single function/class Multiple components Full system
Dependencies All mocked Partial real All real
Speed Fast (ms) Medium (s) Slow (min)
Pattern AAA (Arrange-Act-Assert) AAA or GWT GWT (Given-When-Then)
Isolation Complete Partial None
Purpose Verify logic Verify integration Verify behavior

Test Pyramid Distribution

    /\      E2E Tests (10%)
   /  \     - Full Kafka flow, self-healing scenarios
  /----\    Integration Tests (30%)
 /      \   - RdKafka wrapper validation, Schema Registry
/--------\  Unit Tests (60%)
            - Core logic, utilities, error handling

When to Write E2E Tests

  • MUST Test: Critical user flows, async message processing, multi-component interactions
  • SHOULD Test: API endpoints, error handling flows, authentication/authorization
  • NICE TO HAVE: Edge cases, performance scenarios, recovery mechanisms

Test File Organization

project/
├── src/
│   └── *.spec.ts          # Unit tests (co-located)
└── test/
    ├── e2e/               # E2E tests
    │   ├── *.e2e-spec.ts  # Test files
    │   ├── setup.ts       # Global setup
    │   └── helpers/       # Test utilities
    ├── fixtures/          # Reusable test data
    └── jest-e2e.config.ts # E2E Jest config

E2E Test Lifecycle

beforeAll (90s timeout)
├── Start Docker infrastructure
├── Wait for services healthy
├── Initialize NestJS app
├── Connect Kafka microservice
└── Pre-subscribe to topics (if Kafka)

beforeEach
├── Wait for in-flight operations (1-2s)
└── Clear data (DB collections, message buffers)

test
├── GIVEN: Setup test data
├── WHEN: Execute single action
└── THEN: Verify outcomes

afterEach
└── Clean up test data

afterAll (30s timeout)
├── Close app
├── Disconnect clients
└── Stop infrastructure (if applicable)

Key Principles

  1. Test Isolation: Each test must be independent and not affect others
  2. Real Infrastructure: Use real databases, message brokers, not mocks
  3. Deterministic Results: Tests must produce same results on every run
  4. Clear Intent: Test names and structure must clearly describe behavior
  5. Fast Feedback: Optimize for quick failure detection while maintaining reliability

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides comprehensive workflows and reference materials for E2E testing in TypeScript/NestJS projects. It uses standard development tools like Jest, Docker, and shell commands. No malicious patterns or security risks were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    30/103 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 3bcc7a6. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 5 months ago
  • TypeScript
  • jest
  • nestjs
  • e2e-testing
  • supertest
  • docker
  • kafka
  • postgres
  • mongodb
  • redis
  • integration-testing
  • gwt-pattern

README badge

README badge for bmad-labs/skills

Writes E2E and integration tests for NestJS projects using Jest and supertest against real Docker infrastructure (Kafka, PostgreSQL, MongoDB, Redis) following the Given-When-Then pattern. Covers test setup, writing, review, debugging, and optimization workflows with technology-specific helpers and isolation strategies for each service.

Generated from the current SKILL.md.

Does this skill work with NestJS only?
The skill is built for NestJS projects using Jest and supertest, but the patterns and workflows apply to any TypeScript backend with HTTP endpoints. Technology-specific helpers exist for Kafka, PostgreSQL, MongoDB, and Redis.
Do I need Docker running to use this skill?
Yes. The skill assumes real infrastructure via Docker (Kafka, PostgreSQL, MongoDB, Redis). Tests execute against actual services, not mocks.
What if my E2E tests are flaky or failing?
The Debugging E2E Test workflow provides a systematic protocol: fix one test at a time using isolated test runs, verify with 3-5 consecutive runs before moving to the next failure, then run the full suite only once all tests pass individually.
Does this skill cover GraphQL or gRPC testing?
Yes. The API testing reference includes examples for REST, GraphQL, and gRPC, plus external API mocking with MSW and Nock.
What is the Given-When-Then pattern and is it mandatory?
GWT is the mandatory test structure: Given describes setup state, When describes the action under test, Then describes expected outcomes. All E2E tests in this skill must follow this pattern.

Generated from the current SKILL.md. These answers refresh after source changes.