configure-integration-tests
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/configure:integration-tests
/configure:集成测试
Check and configure integration testing infrastructure for testing service interactions, databases, and external dependencies.
检查并配置用于测试服务交互、数据库及外部依赖的集成测试基础设施。
When to Use This Skill
何时使用该技能
| Use this skill when... | Use another approach when... |
|---|---|
| Setting up integration testing infrastructure with Supertest, pytest, or Testcontainers | Writing individual integration test cases for specific endpoints |
| Creating docker-compose.test.yml for local test service containers | Running existing integration tests ( |
| Auditing integration test setup for completeness (fixtures, factories, CI) | Configuring unit test runners ( |
| Adding integration test jobs to GitHub Actions with service containers | Debugging a specific failing integration test |
| Separating integration tests from unit tests in project structure | Setting up API contract testing ( |
| 以下场景使用该技能... | 以下场景使用其他方案... |
|---|---|
| 使用Supertest、pytest或Testcontainers搭建集成测试基础设施 | 为特定端点编写单个集成测试用例 |
| 创建docker-compose.test.yml用于本地测试服务容器 | 运行已有的集成测试( |
| 审核集成测试设置的完整性(fixtures、工厂、CI) | 配置单元测试运行器(改用 |
| 为GitHub Actions添加包含服务容器的集成测试任务 | 调试特定失败的集成测试 |
| 在项目结构中分离集成测试与单元测试 | 配置API契约测试(改用 |
Context
上下文
- Project root: !
pwd - Package files: !
find . -maxdepth 1 \( -name 'package.json' -o -name 'pyproject.toml' -o -name 'Cargo.toml' -o -name 'go.mod' \) 2>/dev/null - Integration tests dir: !
find tests -maxdepth 1 -type d -name 'integration' 2>/dev/null - Docker compose test: !
find . -maxdepth 1 -name 'docker-compose.test.yml' 2>/dev/null - Vitest integration config: !
find . -maxdepth 1 -name 'vitest.integration.config.*' 2>/dev/null - Supertest dep: !
grep -l 'supertest' package.json 2>/dev/null - Testcontainers dep: !
grep -l 'testcontainers' package.json pyproject.toml 2>/dev/null - Project standards: !
find . -maxdepth 1 -name '.project-standards.yaml' 2>/dev/null
- 项目根目录: !
pwd - 包文件: !
find . -maxdepth 1 \( -name 'package.json' -o -name 'pyproject.toml' -o -name 'Cargo.toml' -o -name 'go.mod' \) 2>/dev/null - 集成测试目录: !
find tests -maxdepth 1 -type d -name 'integration' 2>/dev/null - Docker测试编排文件: !
find . -maxdepth 1 -name 'docker-compose.test.yml' 2>/dev/null - Vitest集成配置: !
find . -maxdepth 1 -name 'vitest.integration.config.*' 2>/dev/null - Supertest依赖: !
grep -l 'supertest' package.json 2>/dev/null - Testcontainers依赖: !
grep -l 'testcontainers' package.json pyproject.toml 2>/dev/null - 项目标准: !
find . -maxdepth 1 -name '.project-standards.yaml' 2>/dev/null
Parameters
参数
Parse from command arguments:
- : Report compliance status without modifications (CI/CD mode)
--check-only - : Apply fixes automatically without prompting
--fix - : Override framework detection
--framework <supertest|pytest|testcontainers>
Integration Testing Stacks:
- JavaScript/TypeScript: Supertest + Testcontainers
- Python: pytest + testcontainers-python + httpx
- Rust: cargo test with + testcontainers-rs
#[ignore] - Go: testing + testcontainers-go
Key Difference from Unit Tests:
- Integration tests interact with real databases, APIs, and services
- They test component boundaries and data flow
- They typically require test fixtures and cleanup
从命令参数中解析:
- : 仅报告合规状态,不进行修改(CI/CD模式)
--check-only - : 自动应用修复,无需提示
--fix - : 覆盖框架自动检测
--framework <supertest|pytest|testcontainers>
集成测试技术栈:
- JavaScript/TypeScript: Supertest + Testcontainers
- Python: pytest + testcontainers-python + httpx
- Rust: cargo test搭配+ testcontainers-rs
#[ignore] - Go: testing + testcontainers-go
与单元测试的核心区别:
- 集成测试与真实数据库、API及服务交互
- 测试组件边界与数据流
- 通常需要测试fixtures与清理操作
Execution
执行流程
Execute this integration testing compliance check:
执行以下集成测试合规性检查:
Step 1: Detect existing integration testing infrastructure
步骤1:检测现有集成测试基础设施
Check for these indicators:
| Indicator | Component | Status |
|---|---|---|
| Integration tests | Present |
| Container testing | Configured |
| HTTP testing | Configured |
| Test services | Present |
| pytest integration | Configured |
检查以下指标:
| 指标 | 组件 | 状态 |
|---|---|---|
| 集成测试 | 已存在 |
依赖中包含 | 容器测试 | 已配置 |
package.json中包含 | HTTP测试 | 已配置 |
| 测试服务 | 已存在 |
带有 | pytest集成 | 已配置 |
Step 2: Analyze current state
步骤2:分析当前状态
Check for complete integration testing setup:
Test Organization:
- directory exists
tests/integration/ - Integration tests separated from unit tests
- Test fixtures and factories present
- Database seeding/migration scripts
JavaScript/TypeScript (Supertest):
- installed
supertest - or similar installed
@testcontainers/postgresql - Test database configuration
- API endpoint tests present
- Authentication test helpers
Python (pytest + testcontainers):
- installed
testcontainers - or
httpxfor HTTP testingrequests - for async tests
pytest-asyncio - marker defined
integration - Database fixtures in
conftest.py
Container Infrastructure:
- exists
docker-compose.test.yml - Test database container defined
- Redis/cache container (if needed)
- Network isolation configured
检查集成测试设置是否完整:
测试组织:
- 存在目录
tests/integration/ - 集成测试与单元测试分离
- 存在测试fixtures和工厂
- 存在数据库填充/迁移脚本
JavaScript/TypeScript(Supertest):
- 已安装
supertest - 已安装或类似包
@testcontainers/postgresql - 测试数据库已配置
- 存在API端点测试
- 存在认证测试辅助工具
Python(pytest + testcontainers):
- 已安装
testcontainers - 已安装或
httpx用于HTTP测试requests - 已安装用于异步测试
pytest-asyncio - 已定义标记
integration - 中存在数据库fixtures
conftest.py
容器基础设施:
- 存在
docker-compose.test.yml - 已定义测试数据库容器
- 已定义Redis/缓存容器(如需要)
- 已配置网络隔离
Step 3: Generate compliance report
步骤3:生成合规性报告
Print a formatted compliance report:
Integration Testing Compliance Report
======================================
Project: [name]
Language: [TypeScript | Python | Rust | Go]
Test Organization:
Integration directory tests/integration/ [EXISTS | MISSING]
Separated from unit not in src/ [CORRECT | MIXED]
Test fixtures tests/fixtures/ [EXISTS | MISSING]
Database seeds tests/seeds/ [EXISTS | N/A]
Framework Setup:
HTTP testing supertest/httpx [INSTALLED | MISSING]
Container testing testcontainers [INSTALLED | MISSING]
Async support pytest-asyncio [INSTALLED | N/A]
Infrastructure:
docker-compose.test.yml test services [EXISTS | MISSING]
Test database PostgreSQL/SQLite [CONFIGURED | MISSING]
Service isolation network config [CONFIGURED | MISSING]
CI/CD Integration:
Integration test job GitHub Actions [CONFIGURED | MISSING]
Service containers workflow services [CONFIGURED | MISSING]
Overall: [X issues found]
Recommendations:
- Install testcontainers for database testing
- Create docker-compose.test.yml for local testing
- Add integration test job to CI workflowIf , stop here.
--check-only打印格式化的合规性报告:
集成测试合规性报告
======================================
项目: [名称]
语言: [TypeScript | Python | Rust | Go]
测试组织:
集成测试目录 tests/integration/ [已存在 | 缺失]
与单元测试分离 不在src/目录中 [正确 | 混合]
测试fixtures tests/fixtures/ [已存在 | 缺失]
数据库填充脚本 tests/seeds/ [已存在 | 不适用]
框架设置:
HTTP测试 supertest/httpx [已安装 | 缺失]
容器测试 testcontainers [已安装 | 缺失]
异步支持 pytest-asyncio [已安装 | 不适用]
基础设施:
docker-compose.test.yml 测试服务 [已存在 | 缺失]
测试数据库 PostgreSQL/SQLite [已配置 | 缺失]
服务隔离 网络配置 [已配置 | 缺失]
CI/CD集成:
集成测试任务 GitHub Actions [已配置 | 缺失]
服务容器 工作流服务 [已配置 | 缺失]
整体状态: [发现X个问题]
建议:
- 安装testcontainers用于数据库测试
- 创建docker-compose.test.yml用于本地测试
- 为CI工作流添加集成测试任务如果使用参数,流程到此结束。
--check-onlyStep 4: Configure integration testing (if --fix or user confirms)
步骤4:配置集成测试(如果使用--fix或用户确认)
Apply configuration based on detected project type. Use templates from REFERENCE.md:
- Install dependencies (supertest, testcontainers, etc.)
- Create test directory () with setup files
tests/integration/ - Create sample tests for API endpoints and database operations
- Create Vitest integration config (JS/TS) or pytest markers (Python)
- Add scripts to package.json or create run commands
根据检测到的项目类型应用配置,使用REFERENCE.md中的模板:
- 安装依赖(supertest、testcontainers等)
- 创建测试目录()及设置文件
tests/integration/ - 创建示例测试,覆盖API端点和数据库操作
- 创建Vitest集成配置(JS/TS)或pytest标记(Python)
- 添加脚本到package.json或创建运行命令
Step 5: Create container infrastructure
步骤5:创建容器基础设施
Create with:
docker-compose.test.yml- PostgreSQL test database (tmpfs for speed)
- Redis test instance (if needed)
- Network isolation
Add corresponding npm/bun scripts for managing test containers. Use templates from REFERENCE.md.
创建,包含:
docker-compose.test.yml- PostgreSQL测试数据库(使用tmpfs提升速度)
- Redis测试实例(如需要)
- 网络隔离
添加对应的npm/bun脚本用于管理测试容器,使用REFERENCE.md中的模板。
Step 6: Configure CI/CD integration
步骤6:配置CI/CD集成
Add integration test job to with:
.github/workflows/test.yml- Service containers (postgres, redis)
- Database migration step
- Integration test execution
- Artifact upload for test results
Use the CI workflow template from REFERENCE.md.
向添加集成测试任务,包含:
.github/workflows/test.yml- 服务容器(postgres、redis)
- 数据库迁移步骤
- 集成测试执行
- 测试结果工件上传
使用REFERENCE.md中的CI工作流模板。
Step 7: Create test fixtures and factories
步骤7:创建测试fixtures和工厂
Create (or Python equivalent) with:
tests/fixtures/factories.ts- Data factory functions using faker
- Database seeding helpers
- Cleanup utilities
Use factory templates from REFERENCE.md.
创建(或Python等效文件),包含:
tests/fixtures/factories.ts- 使用faker的数据工厂函数
- 数据库填充辅助工具
- 清理工具
使用REFERENCE.md中的工厂模板。
Step 8: Update standards tracking
步骤8:更新标准跟踪
Update :
.project-standards.yamlyaml
standards_version: "2025.1"
last_configured: "[timestamp]"
components:
integration_tests: "2025.1"
integration_tests_framework: "[supertest|pytest|testcontainers]"
integration_tests_containers: true
integration_tests_ci: true更新:
.project-standards.yamlyaml
standards_version: "2025.1"
last_configured: "[时间戳]"
components:
integration_tests: "2025.1"
integration_tests_framework: "[supertest|pytest|testcontainers]"
integration_tests_containers: true
integration_tests_ci: trueStep 9: Print final report
步骤9:打印最终报告
Print a summary of changes applied, scripts added, and next steps for running integration tests.
For detailed templates and code examples, see REFERENCE.md.
打印已应用的变更、添加的脚本以及运行集成测试的后续步骤。
如需详细模板和代码示例,请查看REFERENCE.md。
Agentic Optimizations
Agent优化命令
| Context | Command |
|---|---|
| Quick compliance check | |
| Auto-fix all issues | |
| Run integration tests (JS) | |
| Run integration tests (Python) | |
| Start test containers | |
| Check container health | `docker compose -f docker-compose.test.yml ps --format json |
| 上下文 | 命令 |
|---|---|
| 快速合规性检查 | |
| 自动修复所有问题 | |
| 运行集成测试(JS) | |
| 运行集成测试(Python) | |
| 启动测试容器 | |
| 检查容器健康状态 | `docker compose -f docker-compose.test.yml ps --format json |
Flags
标志
| Flag | Description |
|---|---|
| Report status without offering fixes |
| Apply all fixes automatically without prompting |
| Override framework detection (supertest, pytest, testcontainers) |
| 标志 | 描述 |
|---|---|
| 仅报告状态,不提供修复选项 |
| 自动应用所有修复,无需提示 |
| 覆盖框架自动检测(supertest、pytest、testcontainers) |
Examples
示例
bash
undefinedbash
undefinedCheck compliance and offer fixes
检查合规性并提供修复选项
/configure:integration-tests
/configure:integration-tests
Check only, no modifications
仅检查,不修改
/configure:integration-tests --check-only
/configure:integration-tests --check-only
Auto-fix all issues
自动修复所有问题
/configure:integration-tests --fix
/configure:integration-tests --fix
Force specific framework
强制使用特定框架
/configure:integration-tests --fix --framework pytest
undefined/configure:integration-tests --fix --framework pytest
undefinedError Handling
错误处理
- No app entry point found: Ask user to specify app location
- Docker not available: Warn about testcontainers requirement
- Database type unknown: Ask user to specify database type
- Port conflicts: Suggest alternative ports in docker-compose
- 未找到应用入口: 询问用户指定应用位置
- Docker不可用: 警告Testcontainers的依赖要求
- 数据库类型未知: 询问用户指定数据库类型
- 端口冲突: 建议在docker-compose中使用替代端口
See Also
相关链接
- - Unit testing configuration
/configure:tests - - API contract testing
/configure:api-tests - - Coverage configuration
/configure:coverage - - Run all compliance checks
/configure:all - Testcontainers documentation: https://testcontainers.com
- Supertest documentation: https://github.com/ladjs/supertest
- - 单元测试配置
/configure:tests - - API契约测试
/configure:api-tests - - 覆盖率配置
/configure:coverage - - 运行所有合规性检查
/configure:all - Testcontainers文档: https://testcontainers.com
- Supertest文档: https://github.com/ladjs/supertest