no-export
Configuration
Rule Details
Disallow exporting from files that contain Jest tests or suites. If a file has at least one test or describe (including equivalent aliases and chained forms), this rule reports any export in that file.
Exporting from a test file is risky because importing that file runs its tests again in every consumer. That can duplicate test runs, slow down suites, and make failures harder to trace. Move shared helpers into a separate non-test module instead.
This rule checks:
- ES module exports (
export const,export default,export =, and otherexportforms) - CommonJS-style assignments rooted at
module.exports(includingmodule["exports"]and deeply nested properties)
Locally declared variables or parameters named module are not treated as the CommonJS global. Files that export but contain no Jest tests or suites are allowed.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
When Not To Use It
Do not enable this rule on files that are not Jest test files. For shared test utilities that must export helpers, either disable the rule for those files or keep helpers in a dedicated module that does not define tests.