redline
HighTests and CIexit-in-test

Exits from a test

Exits from a test. process.exit(0) ends the test run early, with a passing exit code.

This is how the comment reads inline, under the flagged line.

Why it matters

Exiting with 0 from inside a test makes the runner report success no matter what ran or failed.

What to do

Delete the exit. Let the test runner finish.

Examples

Flagged
process.exit(0);
Better
expect(code).toBe(0);

What it catches

It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: Test files only. These cases are the rule's own tests: the first set must be flagged and the second must not.

Flagged

process.exit(0);

Left alone

expect(code).toBe(0);

Research

`process.exit(0)` or `sys.exit(0)` in tests or test helpers. The run ends as a pass before later assertions execute.

Turn it off or change it

In a config file for the CLI, or in the API's rules field:

{
  "rules": {
    "disable": [
      "exit-in-test"
    ],
    "severity": {
      "exit-in-test": "low"
    }
  }
}

Read the source or report a false positive.