← 返回
未分类 中文

Jest Config Validator

Validate jest.config.ts/js/json and Jest configuration in package.json for deprecated options, transform conflicts, and best practices. Use when validating J...
检查并验证 jest.config.ts/js/json 和 package.json 中的 Jest 配置,识别已弃用的选项、转换冲突及最佳实践。适用于验证 Jest 配置的场景。
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.1 1 版本 99764.2 Key: 无需
★ 0
Stars
📥 423
下载
💾 1
安装
1
版本
#latest

概述

Jest Config Validator

Validate jest.config.ts, jest.config.js, jest.config.json, and package.json#jest for deprecated options, transform conflicts, coverage misconfigurations, and best practices. Supports text, JSON, and summary output formats with CI-friendly exit codes.

Commands

# Full validation (all 22+ rules)
python3 scripts/jest_config_validator.py validate jest.config.js

# Quick syntax-only check (structure rules only)
python3 scripts/jest_config_validator.py check jest.config.ts

# Explain config in human-readable form
python3 scripts/jest_config_validator.py explain jest.config.json

# Suggest improvements
python3 scripts/jest_config_validator.py suggest package.json

# JSON output (CI-friendly)
python3 scripts/jest_config_validator.py validate jest.config.js --format json

# Summary only (pass/fail + counts)
python3 scripts/jest_config_validator.py validate jest.config.js --format summary

# Strict mode (warnings become errors)
python3 scripts/jest_config_validator.py validate jest.config.js --strict

Rules (22+)

#CategorySeverityRule
-----------------------------
S1StructureErrorFile not found or unreadable
S2StructureErrorEmpty config or missing module.exports/export default
S3StructureWarningBoth jest.config and package.json#jest present (conflict)
S4StructureWarningUnknown top-level config keys detected
S5StructureErrorInvalid JSON syntax (for .json configs)
T1Test EnvironmentErrorInvalid testEnvironment value
T2Test EnvironmentWarningtestEnvironment: jsdom without jest-environment-jsdom (Jest 28+)
T3Test EnvironmentWarningtestURL deprecated in Jest 28+ (use testEnvironmentOptions)
T4Test EnvironmentWarningEmpty testMatch or testPathPattern
X1TransformsWarningOverlapping transform patterns (conflict)
X2TransformsWarningts-jest and babel-jest used together without clear separation
X3TransformsWarningtransformIgnorePatterns too broad (may skip needed transforms)
X4TransformsWarningMissing transform for .tsx/.jsx when React detected
V1CoverageWarningcollectCoverageFrom empty or too broad
V2CoverageWarningcoverageThreshold set but collectCoverage not enabled
V3CoverageWarningDeprecated coverageReporters values
D1DeprecatedWarningDeprecated Jest options detected
D2DeprecatedWarningjest.fn() used inside config file (configs should not mock)
D3DeprecatedWarningtimers: 'fake' (old syntax, use fakeTimers object)
B1Best PracticesInfoNo clearMocks/resetMocks/restoreMocks set
B2Best PracticesWarningroots pointing outside project directory
B3Best PracticesWarningsetupFiles/setupFilesAfterFramework path pattern issues
B4Best PracticesInfomoduleNameMapper with complex regex missing comment
B5Best PracticesWarningpreset and manual config overlap
B6Best PracticesWarningmaxWorkers set to 1 in non-CI context

Output Formats

text (default): Human-readable with file path, rule code, severity, and message per finding.

json: Machine-readable JSON with file, summary, and findings array. Each finding has rule, severity, message, and line fields.

summary: One-line pass/fail with error/warning/info counts. Ideal for CI output gates.

Exit Codes

CodeMeaning
---------------
0No errors found (warnings/info may exist)
1One or more errors found
2File not found or parse error

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-03 10:26 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 195 📥 67,590
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 72 📥 181,702
ai-agent

Slack Messaging

charlie-morrison
Slack 消息—通过 CLI 和 API 发送消息、管理频道、上传文件、添加反应并自动化团队通知。
★ 0 📥 495