Skip to content

production-does-not-import-tests

Field Value
Tool Dependency Cruiser
Enable via layout({ scope })
Severity error
Kind dependency rule
Source packages/rules/src/dependency-cruiser.cjs
Docs packages/rules/docs/dependency-cruiser.md

Production code importing tests.

{
"name": "production-does-not-import-tests",
"severity": "error",
"from": {
"path": "^(?:apps|packages)/[^/]+/src(?:/|$)",
"pathNot": "(?:^|/)(?:tests?|__tests__)(?:/|$)|[.](?:test|spec)[.][^/]+$"
},
"to": {
"path": "(?:^|/)(?:tests?|__tests__)(?:/|$)|[.](?:test|spec)[.][^/]+$"
}
}

This rule is one of several in the Dependency Cruiser preset. The Dependency Cruiser page carries the full preset docs from packages/rules/docs/dependency-cruiser.md.

All rules · Dependency Cruiser rules