Jest Config Validator

Other

Validate jest.config.ts/js/json and Jest configuration in package.json for deprecated options, transform conflicts, and best practices. Use when validating Jest test runner configs, auditing test setups, migrating Jest versions, or linting jest.config files.

Install

openclaw skills install jest-config-validator

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