configure-tests
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/configure:tests
/configure:tests
Check and configure testing frameworks against best practices (Vitest, Jest, pytest, cargo-nextest).
根据最佳实践检查并配置测试框架(Vitest、Jest、pytest、cargo-nextest)。
When to Use This Skill
何时使用该技能
| Use this skill when... | Use another approach when... |
|---|---|
| Setting up testing infrastructure | Just running tests (use |
| Checking test framework configuration | Tests already properly configured |
| Migrating to modern test frameworks (Vitest, pytest, nextest) | Writing individual tests (write tests directly) |
| Validating coverage configuration | Debugging failing tests (check test output) |
| Ensuring test best practices | Simple project with no testing needed |
| 使用该技能的场景... | 使用其他方法的场景... |
|---|---|
| 搭建测试基础设施 | 仅运行测试(使用 |
| 检查测试框架配置 | 测试已正确配置完成 |
| 迁移至现代测试框架(Vitest、pytest、nextest) | 编写单个测试用例(直接编写测试) |
| 验证覆盖率配置 | 调试失败的测试(查看测试输出) |
| 确保测试符合最佳实践 | 无需测试的简单项目 |
Context
上下文信息
- Package.json: !
find . -maxdepth 1 -name \'package.json\' 2>/dev/null - Pyproject.toml: !
find . -maxdepth 1 -name \'pyproject.toml\' 2>/dev/null - Cargo.toml: !
find . -maxdepth 1 -name \'Cargo.toml\' 2>/dev/null - Test config files: !
find . -maxdepth 1 \( -name 'vitest.config.*' -o -name 'jest.config.*' -o -name 'pytest.ini' -o -name '.nextest.toml' \) 2>/dev/null - Pytest in pyproject: !
grep -c 'tool.pytest' pyproject.toml 2>/dev/null - Test directories: !
find . -maxdepth 2 -type d \( -name 'tests' -o -name '__tests__' -o -name 'test' \) 2>/dev/null - Test scripts in package.json: !
grep -m5 -o '"test[^"]*"' package.json 2>/dev/null - Coverage config: !
grep -l 'coverage' vitest.config.* jest.config.* 2>/dev/null - Project standards: !
head -20 .project-standards.yaml 2>/dev/null
Modern testing stack preferences:
- JavaScript/TypeScript: Vitest (preferred) or Jest
- Python: pytest with pytest-cov
- Rust: cargo-nextest for improved performance
- Package.json: !
find . -maxdepth 1 -name \'package.json\' 2>/dev/null - Pyproject.toml: !
find . -maxdepth 1 -name \'pyproject.toml\' 2>/dev/null - Cargo.toml: !
find . -maxdepth 1 -name \'Cargo.toml\' 2>/dev/null - 测试配置文件: !
find . -maxdepth 1 \( -name 'vitest.config.*' -o -name 'jest.config.*' -o -name 'pytest.ini' -o -name '.nextest.toml' \) 2>/dev/null - pyproject中的pytest配置: !
grep -c 'tool.pytest' pyproject.toml 2>/dev/null - 测试目录: !
find . -maxdepth 2 -type d \( -name 'tests' -o -name '__tests__' -o -name 'test' \) 2>/dev/null - package.json中的测试脚本: !
grep -m5 -o '"test[^"]*"' package.json 2>/dev/null - 覆盖率配置: !
grep -l 'coverage' vitest.config.* jest.config.* 2>/dev/null - 项目标准: !
head -20 .project-standards.yaml 2>/dev/null
现代测试技术栈偏好:
- JavaScript/TypeScript:Vitest(优先推荐)或Jest
- Python:搭配pytest-cov的pytest
- Rust:性能更优的cargo-nextest
Parameters
参数
Parse these from :
$ARGUMENTS| Flag | Description |
|---|---|
| Report status without offering fixes |
| Apply all fixes automatically without prompting |
| Override framework detection ( |
从中解析以下参数:
$ARGUMENTS| 标记 | 说明 |
|---|---|
| 仅报告状态,不提供修复方案 |
| 自动应用所有修复,无需确认 |
| 覆盖框架自动检测结果(可选值: |
Version Checking
版本检查
CRITICAL: Before flagging outdated versions, verify latest releases:
- Vitest: Check vitest.dev or GitHub releases
- Jest: Check jestjs.io or npm
- pytest: Check pytest.org or PyPI
- cargo-nextest: Check nexte.st or GitHub releases
Use WebSearch or WebFetch to verify current versions before reporting outdated frameworks.
关键注意事项:在标记版本过时前,请先验证最新版本:
- Vitest:查看vitest.dev或GitHub releases
- Jest:查看jestjs.io或npm
- pytest:查看pytest.org或PyPI
- cargo-nextest:查看nexte.st或GitHub releases
在报告框架版本过时前,请使用WebSearch或WebFetch工具验证当前最新版本。
Execution
执行步骤
Execute this testing framework compliance check:
执行以下测试框架合规性检查:
Step 1: Detect framework
步骤1:检测框架
Identify the project language and existing test framework:
| Indicator | Language | Detected Framework |
|---|---|---|
| JavaScript/TypeScript | Vitest |
| JavaScript/TypeScript | Jest |
| Python | pytest |
| Python | pytest |
| Rust | cargo test |
| Rust | cargo-nextest |
If flag is provided, use that value instead.
--framework识别项目语言及已存在的测试框架:
| 识别标识 | 语言 | 检测到的框架 |
|---|---|---|
| JavaScript/TypeScript | Vitest |
| JavaScript/TypeScript | Jest |
| Python | pytest |
| Python | pytest |
| Rust | cargo test |
| Rust | cargo-nextest |
若提供了标记,则使用该标记指定的框架。
--frameworkStep 2: Analyze current state
步骤2:分析当前状态
Read the detected framework's configuration and check completeness. For each framework, verify:
Vitest:
- Config file exists (or
vitest.config.ts).js - configured for compatibility
globals: true - set appropriately (jsdom, happy-dom, node)
environment - Coverage configured with or
@vitest/coverage-v8@vitest/coverage-istanbul - Watch mode exclusions configured
Jest:
- Config file exists (or
jest.config.js).ts - configured
testEnvironment - Coverage configuration present
- Transform configured for TypeScript/JSX
- Module path aliases configured
pytest:
- has
pyproject.tomlsection[tool.pytest.ini_options] - configured
testpaths - includes useful flags (
addopts,-v)--strict-markers - defined for test categorization
markers - installed
pytest-cov
cargo-nextest:
- exists
.nextest.toml - Profile configurations (default, ci)
- Retry policy configured
- Test groups defined if needed
读取检测到的框架配置并检查完整性。针对每个框架,验证以下内容:
Vitest:
- 配置文件存在(或
vitest.config.ts).js - 已配置以确保兼容性
globals: true - 已正确设置(jsdom、happy-dom、node)
environment - 已通过或
@vitest/coverage-v8配置覆盖率@vitest/coverage-istanbul - 已配置监听模式排除项
Jest:
- 配置文件存在(或
jest.config.js).ts - 已配置
testEnvironment - 存在覆盖率配置
- 已为TypeScript/JSX配置转换规则
- 已配置模块路径别名
pytest:
- 中包含
pyproject.toml章节[tool.pytest.ini_options] - 已配置
testpaths - 包含实用标记(
addopts、-v)--strict-markers - 已定义用于测试分类
markers - 已安装
pytest-cov
cargo-nextest:
- 存在
.nextest.toml - 已配置Profile(默认、ci)
- 已配置重试策略
- 按需定义了测试分组
Step 3: Report results
步骤3:报告结果
Print a compliance report with:
- Detected framework and version
- Configuration check results for each item
- Test organization (unit/integration/e2e directories)
- Package scripts status (test, test:watch, test:coverage)
- Overall issue count and recommendations
If , stop here.
--check-only输出合规性报告,包含:
- 检测到的框架及版本
- 各项配置的检查结果
- 测试组织方式(单元/集成/e2e目录)
- 包脚本状态(test、test:watch、test:coverage)
- 问题总数及改进建议
若使用标记,执行至此结束。
--check-onlyStep 4: Apply fixes (if --fix or user confirms)
步骤4:应用修复(若使用--fix或用户确认)
Install dependencies and create configuration using templates from REFERENCE.md:
- Missing config: Create framework config file from template
- Missing dependencies: Install required packages
- Missing coverage: Add coverage configuration with 80% threshold
- Missing scripts: Add test scripts to package.json
- Missing test directories: Create standard test directory structure
从REFERENCE.md中获取模板,安装依赖并创建配置:
- 缺失配置:从模板创建框架配置文件
- 缺失依赖:安装所需包
- 缺失覆盖率配置:添加覆盖率配置,阈值设为80%
- 缺失脚本:向package.json中添加测试脚本
- 缺失测试目录:创建标准测试目录结构
Step 5: Set up test organization
步骤5:设置测试组织方式
Create standard test directory structure for the detected language. See directory structure patterns in REFERENCE.md.
为检测到的语言创建标准测试目录结构。目录结构模式请参考REFERENCE.md。
Step 6: Configure CI/CD integration
步骤6:配置CI/CD集成
Check for test commands in GitHub Actions workflows. If missing, add CI test commands using the CI templates from REFERENCE.md.
检查GitHub Actions工作流中是否包含测试命令。若缺失,使用REFERENCE.md中的CI模板添加CI测试命令。
Step 7: Handle migration (if upgrading)
步骤7:处理迁移(若升级框架)
If migrating between frameworks (e.g., Jest to Vitest, unittest to pytest), follow the migration guide in REFERENCE.md.
若在框架间迁移(如从Jest迁移到Vitest,从unittest迁移到pytest),请遵循REFERENCE.md中的迁移指南。
Step 8: Update standards tracking
步骤8:更新标准跟踪文件
Update :
.project-standards.yamlyaml
standards_version: "2025.1"
last_configured: "<timestamp>"
components:
tests: "2025.1"
tests_framework: "<vitest|jest|pytest|nextest>"
tests_coverage_threshold: 80
tests_ci_integrated: trueFor detailed configuration templates, migration guides, CI/CD integration examples, and directory structure patterns, see REFERENCE.md.
更新:
.project-standards.yamlyaml
standards_version: "2025.1"
last_configured: "<timestamp>"
components:
tests: "2025.1"
tests_framework: "<vitest|jest|pytest|nextest>"
tests_coverage_threshold: 80
tests_ci_integrated: true详细的配置模板、迁移指南、CI/CD集成示例及目录结构模式,请查看REFERENCE.md。
Agentic Optimizations
智能优化
| Context | Command |
|---|---|
| Detect test framework | |
| Check coverage config | |
| List test files | |
| Quick compliance check | |
| Auto-fix configuration | |
| 上下文 | 命令 |
|---|---|
| 检测测试框架 | |
| 检查覆盖率配置 | |
| 列出测试文件 | |
| 快速合规性检查 | |
| 自动修复配置 | |
Error Handling
错误处理
- No package.json found: Cannot configure JS/TS tests, skip or error
- Conflicting frameworks: Warn about multiple test configs, require manual resolution
- Missing dependencies: Offer to install required packages
- Invalid config syntax: Report parse error, offer to replace with template
- 未找到package.json:无法配置JS/TS测试,跳过或抛出错误
- 框架冲突:警告存在多个测试配置,需手动解决
- 缺失依赖:提示安装所需包
- 配置语法无效:报告解析错误,提示使用模板替换
See Also
相关内容
- - Configure coverage thresholds and reporting
/configure:coverage - - Run all compliance checks
/configure:all - - Universal test runner
/test:run - - Comprehensive testing infrastructure setup
/test:setup - Vitest documentation: https://vitest.dev
- pytest documentation: https://docs.pytest.org
- cargo-nextest documentation: https://nexte.st
- - 配置覆盖率阈值与报告
/configure:coverage - - 运行所有合规性检查
/configure:all - - 通用测试运行器
/test:run - - 全面测试基础设施搭建
/test:setup - Vitest文档:https://vitest.dev
- pytest文档:https://docs.pytest.org
- cargo-nextest文档:https://nexte.st