Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

quality.testing

Keep test-only modules and guards out of production paths

Production modules should not import test doubles or gate behavior on test-only environment flags.

#Metadata

Rule ID
ts.testing.no-test-only-code-in-production
Severity
high
Confidence
0.8
Languages
javascript, typescript
Presets
recommended, strict
Stability
experimental
Applies to
project
Tags
boundaries, quality, rules-catalog, testing

#Why it matters

Test-only imports and NODE_ENV test branches can ship dead paths or accidental coupling to test harnesses.

#Remediation

Move helpers into shared neutral modules, guard test utilities behind dev-only entrypoints, and keep production code free of `NODE_ENV === 'test'` branches.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/typescript/ts.testing.no-test-only-code-in-production.rule.yaml.