Token导航 LogoToken导航TokenDH.com
开发external-servicegithub未标认证来源可访问许可证需确认审计提醒

typescript-e2e-testingTypeScript E2E 测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

44,064

周安装

1,833

GitHub Stars

8

下载量

14,256
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:typescript-e2e-testing(TypeScript E2E 测试)
来源仓库:https://github.com/bmad-labs/skills
仓库路径:skills/typescript-e2e-testing
安装命令:
npx skills add https://github.com/bmad-labs/skills --skill typescript-e2e-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/bmad-labs/skills --skill typescript-e2e-testing

简介

使用真实的 Docker 基础设施和 GWT 模式完成 TypeScript/NestJS 项目的 E2E 和集成测试。

  • 支持六种引导工作流程:设置、编写、审阅、运行、调试和优化 E2E 测试
  • 通过 Docker 对真实服务(PostgreSQL、MongoDB、Redis、Kafka)进行测试;从不嘲笑基础设施
  • 在所有测试用例中强制执行 Give-When-Then 模式、测试隔离和特定断言
  • 包括针对 Kafka、数据库、Redis 和使用 MSW/Nock 模拟进行 API 测试的特定技术帮助程序、规则和示例

SKILL.md

E2E Testing Skill

E2E testing validates complete workflows from user perspective, using real infrastructure via Docker.


Workflows

For comprehensive step-by-step guidance, use the appropriate workflow:

WorkflowWhen to Use
Setup E2E TestSetting up E2E infrastructure for a new or existing project
Writing E2E TestCreating new E2E test cases with proper GWT pattern
Review E2E TestReviewing existing tests for quality and correctness
Running E2E TestExecuting tests with proper verification
Debugging E2E TestSystematically fixing failing tests
Optimize E2E TestImproving test suite performance

Workflow Selection Guide

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

Detect User Intent → Select Workflow

User Says / WantsWorkflow to LoadFile
"Set up E2E tests", "configure docker-compose", "add E2E to project", "create test helpers"Setupworkflows/setup/workflow.md
"Write E2E tests", "add integration tests", "test this endpoint", "create e2e-spec"Writingworkflows/writing/workflow.md
"Review E2E tests", "check test quality", "audit tests", "is this test correct?"Reviewingworkflows/review/workflow.md
"Run E2E tests", "execute tests", "start docker and test", "check if tests pass"Runningworkflows/running/workflow.md
"Fix E2E tests", "debug tests", "tests are failing", "flaky test", "connection error"Debuggingworkflows/debugging/workflow.md
"Speed up E2E tests", "optimize tests", "tests are slow", "reduce test time"Optimizingworkflows/optimize/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

Important: Each workflow includes instructions to load relevant knowledge from the references/ folder before and after completing tasks.


Knowledge Base Structure

references/
├── common/              # Shared testing fundamentals
│   ├── knowledge.md     # Core E2E concepts and test pyramid
│   ├── rules.md         # Mandatory testing rules (GWT, timeouts, logging)
│   ├── best-practices.md # Test design and cleanup patterns
│   ├── test-case-creation-guide.md # GWT templates for all scenarios
│   ├── nestjs-setup.md  # NestJS app bootstrap and Jest config
│   ├── debugging.md     # VS Code config and log analysis
│   └── examples.md      # Comprehensive examples by category
│
├── kafka/               # Kafka-specific testing
│   ├── knowledge.md     # Why common approaches fail, architecture
│   ├── rules.md         # Kafka-specific testing rules
│   ├── test-helper.md   # KafkaTestHelper implementation
│   ├── docker-setup.md  # Redpanda/Kafka Docker configs
│   ├── performance.md   # Optimization techniques
│   ├── isolation.md     # Pre-subscription pattern details
│   └── examples.md      # Kafka test examples
│
├── postgres/            # PostgreSQL-specific testing
│   ├── knowledge.md     # PostgreSQL testing concepts
│   ├── rules.md         # Cleanup, transaction, assertion rules
│   ├── test-helper.md   # PostgresTestHelper implementation
│   └── examples.md      # CRUD, transaction, constraint examples
│
├── mongodb/             # MongoDB-specific testing
│   ├── knowledge.md     # MongoDB testing concepts
│   ├── rules.md         # Document cleanup and assertion rules
│   ├── test-helper.md   # MongoDbTestHelper implementation
│   ├── docker-setup.md  # Docker and Memory Server setup
│   └── examples.md      # Document and aggregation examples
│
├── redis/               # Redis-specific testing
│   ├── knowledge.md     # Redis testing concepts
│   ├── rules.md         # TTL and pub/sub rules
│   ├── test-helper.md   # RedisTestHelper implementation
│   ├── docker-setup.md  # Docker configuration
│   └── examples.md      # Cache, session, rate limit examples
│
└── api/                 # API testing (REST, GraphQL, gRPC)
    ├── knowledge.md     # API testing concepts
    ├── rules.md         # Request/response assertion rules
    ├── test-helper.md   # Auth and Supertest helpers
    ├── examples.md      # REST, GraphQL, validation examples
    └── mocking.md       # MSW and Nock external API mocking

Quick Reference by Task

Tip: For detailed step-by-step guidance, use the Workflows section above.

Setup New E2E Structure

Workflow: Setup E2E Test

  1. Read references/common/knowledge.md - Understand E2E fundamentals
  2. Read references/common/nestjs-setup.md - Project setup
  3. Read technology-specific docker-setup.md files as needed

Write Test Cases

Workflow: Writing E2E Test

  1. MANDATORY: Read references/common/rules.md - GWT pattern, timeouts
  2. Read references/common/test-case-creation-guide.md - Templates
  3. Read technology-specific files:

- Kafka: references/kafka/knowledge.mdtest-helper.mdisolation.md - PostgreSQL: references/postgres/rules.mdtest-helper.md - MongoDB: references/mongodb/rules.mdtest-helper.md - Redis: references/redis/rules.mdtest-helper.md - API: references/api/rules.mdtest-helper.md

Review Test Quality

Workflow: Review E2E Test

  1. Read references/common/rules.md - Check against mandatory patterns
  2. Read references/common/best-practices.md - Quality standards
  3. Read technology-specific rules.md files

Run E2E Tests

Workflow: Running E2E Test

  1. Verify Docker infrastructure is running
  2. Run tests sequentially with npm run test:e2e > /tmp/e2e-${E2E_SESSION}-output.log 2>&1
  3. Follow failure protocol if tests fail

Debug Failing Tests

Workflow: Debugging E2E Test

  1. Read references/common/debugging.md
  2. Create /tmp/e2e-${E2E_SESSION}-failures.md tracking file
  3. Fix ONE test at a time

Optimize Test Performance

Workflow: Optimize E2E Test

  1. Read references/common/best-practices.md - Performance patterns
  2. Read references/kafka/performance.md for Kafka tests
  3. Measure baseline before making changes

Examples

  • Read references/common/examples.md for general patterns
  • Read technology-specific examples.md for detailed scenarios

Core Principles

0. Context Efficiency (Temp File Output)

ALWAYS redirect E2E test output to temp files, NOT console. E2E output is verbose and bloats agent context.

IMPORTANT: Redirect output to temp files only (NO console output). Use unique session ID to prevent conflicts.

# Generate unique session ID at start of debugging session
export E2E_SESSION=$(date +%s)-$$

# Standard pattern - redirect to file only (no console output)
npm run test:e2e > /tmp/e2e-${E2E_SESSION}-output.log 2>&1

# Read summary only (last 50 lines)
tail -50 /tmp/e2e-${E2E_SESSION}-output.log

# Get failure details
grep -B 2 -A 15 "FAIL\|✕" /tmp/e2e-${E2E_SESSION}-output.log

# Cleanup when done
rm -f /tmp/e2e-${E2E_SESSION}-*.log /tmp/e2e-${E2E_SESSION}-*.md

Temp Files (with ${E2E_SESSION} unique per agent):

  • /tmp/e2e-${E2E_SESSION}-output.log - Full test output
  • /tmp/e2e-${E2E_SESSION}-failures.log - Filtered failure output
  • /tmp/e2e-${E2E_SESSION}-failures.md - Tracking file for one-by-one fixing
  • /tmp/e2e-${E2E_SESSION}-debug.log - Debug runs
  • /tmp/e2e-${E2E_SESSION}-verify.log - Verification runs

1. Real Infrastructure

Test against actual services via Docker. Never mock databases or message brokers for E2E tests.

2. GWT Pattern (Mandatory)

ALL E2E tests MUST follow Given-When-Then:

it('should create user and return 201', async () => {
  // GIVEN: Valid user data
  const userData = { email: 'test@example.com', name: 'Test' };

  // WHEN: Creating user
  const response = await request(httpServer)
    .post('/users')
    .send(userData)
    .expect(201);

  // THEN: User created with correct data
  expect(response.body.data.email).toBe('test@example.com');
});

3. Test Isolation

Each test MUST be independent:

  • Clean database state in beforeEach
  • Use unique identifiers (consumer groups, topics)
  • Wait for async operations to complete

4. Specific Assertions

Assert exact values, not just existence:

// WRONG
expect(response.body.data).toBeDefined();

// CORRECT
expect(response.body).toMatchObject({
  code: 'SUCCESS',
  data: { email: 'test@example.com', name: 'Test' }
});

Project Structure

project-root/
├── src/
├── test/
│   ├── e2e/
│   │   ├── feature.e2e-spec.ts
│   │   ├── setup.ts
│   │   └── helpers/
│   │       ├── test-app.helper.ts
│   │       ├── postgres.helper.ts
│   │       ├── mongodb.helper.ts
│   │       ├── redis.helper.ts
│   │       └── kafka.helper.ts
│   └── jest-e2e.config.ts
├── docker-compose.e2e.yml
├── .env.e2e
└── package.json

Essential Jest Configuration

// test/jest-e2e.config.ts
const config: Config = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  testMatch: ['**/*.e2e-spec.ts'],
  testTimeout: 25000,
  maxWorkers: 1,           // CRITICAL: Sequential execution
  clearMocks: true,
  forceExit: true,
  detectOpenHandles: true,
};

Technology-Specific Timeouts

TechnologyWait TimeStrategy
Kafka10-20s max (polling)Smart polling with 50ms intervals
PostgreSQL<1sDirect queries
MongoDB<1sDirect queries
Redis<100msIn-memory operations
External API1-5sNetwork latency

Failure Resolution Protocol

CRITICAL: Fix ONE test at a time. NEVER run full suite repeatedly while fixing.

When E2E tests fail:

  1. Initialize session (once at start): export E2E_SESSION=$(date +%s)-$$
  2. Create tracking file: /tmp/e2e-${E2E_SESSION}-failures.md with all failing tests
  3. Select ONE failing test - work on only this test
  4. Run ONLY that test (never full suite): npm run test:e2e -- -t "test name" > /tmp/e2e-${E2E_SESSION}-debug.log 2>&1 tail -50 /tmp/e2e-${E2E_SESSION}-debug.log
  5. Fix the issue - analyze error, make targeted fix
  6. Verify fix - run same test 3-5 times: for i in {1..5}; do npm run test:e2e -- -t "test name" > /tmp/e2e-${E2E_SESSION}-run$i.log 2>&1 && echo "Run $i: PASS" || echo "Run $i: FAIL"; done
  7. Mark as FIXED in tracking file
  8. Move to next failing test - repeat steps 3-7
  9. Run full suite ONLY ONCE after ALL individual tests pass
  10. Cleanup: rm -f /tmp/e2e-${E2E_SESSION}-*.log /tmp/e2e-${E2E_SESSION}-*.md

WHY: Running full suite wastes time and context. Each failing test pollutes output, making debugging harder.


Common Patterns

Database Cleanup (PostgreSQL/MongoDB)

beforeEach(async () => {
  await new Promise(r => setTimeout(r, 500)); // Wait for in-flight
  await repository.clear();  // PostgreSQL
  // OR
  await model.deleteMany({}); // MongoDB
});

Kafka Test Helper Pattern

// Use pre-subscription + buffer clearing (NOT fromBeginning: true)
const kafkaHelper = new KafkaTestHelper();
await kafkaHelper.subscribeToTopic(outputTopic, false);
// In beforeEach: kafkaHelper.clearMessages(outputTopic);

Redis Cleanup

beforeEach(async () => {
  await redis.flushdb();
});

External API Mock (MSW)

mockServer.use(
  http.post('https://api.external.com/endpoint', () => {
    return HttpResponse.json({ status: 'success' });
  })
);

Async Event Verification (Kafka)

// Use smart polling instead of fixed waits
await kafkaHelper.publishEvent(inputTopic, event, event.id);
const messages = await kafkaHelper.waitForMessages(outputTopic, 1, 20000);
expect(messages[0].value).toMatchObject({ id: event.id });

Debugging Commands

All commands redirect output to temp files only (no console output).

# Initialize session (once at start)
export E2E_SESSION=$(date +%s)-$$

# Run specific test (no console output)
npm run test:e2e -- -t "should create user" > /tmp/e2e-${E2E_SESSION}-output.log 2>&1 && tail -50 /tmp/e2e-${E2E_SESSION}-output.log

# Run specific file
npm run test:e2e -- test/e2e/user.e2e-spec.ts > /tmp/e2e-${E2E_SESSION}-output.log 2>&1 && tail -50 /tmp/e2e-${E2E_SESSION}-output.log

# Run full suite
npm run test:e2e > /tmp/e2e-${E2E_SESSION}-output.log 2>&1 && tail -50 /tmp/e2e-${E2E_SESSION}-output.log

# Get failure details from last run
grep -B 2 -A 15 "FAIL\|✕" /tmp/e2e-${E2E_SESSION}-output.log

# Debug with breakpoints (requires console for interactive debugging)
node --inspect-brk node_modules/.bin/jest --config test/jest-e2e.config.ts --runInBand

# View application logs (limited)
tail -100 logs/e2e-test.log
grep -i error logs/e2e-test.log | tail -50

# Cleanup session files
rm -f /tmp/e2e-${E2E_SESSION}-*.log /tmp/e2e-${E2E_SESSION}-*.md

Anti-Patterns to Avoid

  1. Multiple WHEN actions - Split into separate tests
  2. Conditional assertions - Create deterministic test cases
  3. Shared state between tests - Clean in beforeEach
  4. Mocking databases - Use real connections
  5. Skipping cleanup - Always clean before AND after
  6. Fixing multiple tests at once - Fix one at a time
  7. Generic assertions - Assert specific values
  8. fromBeginning: true for Kafka - Use pre-subscription + buffer clearing

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.29%
按下载量换算4,888

Claude

28.94%
按下载量换算4,126

Cursor

19.09%
按下载量换算2,721

Gemini CLI

10.98%
按下载量换算1,565

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills