Skip to content

[Feature]: Add Jest Config Doctor CLI Mode #15913

@Michealjunior

Description

@Michealjunior

🚀 Feature Proposal

Jest currently lacks a dedicated CLI mode to analyze configuration problems. When projects accidentally define multiple configuration sources or misconfigure test patterns so that no tests are discovered, Jest gives little guidance. Users want a safe, non-executing jest --doctor command that reports these issues clearly.

Motivation

Developers frequently encounter confusing behavior when Jest silently resolves multiple configuration sources or fails to discover any tests. Today, Jest provides limited feedback in these scenarios, often leaving users unsure why their test suites are not running. This leads to wasted debugging time, inconsistent setup across teams, and a poor developer experience—especially in large monorepos or projects with evolving configurations.

Introducing a dedicated jest --doctor mode directly addresses these pain points. By resolving configuration exactly as a normal Jest run would—without executing any tests—this mode gives users a safe way to diagnose issues. When both a configuration file and a package.json Jest entry exist, jest --doctor will clearly report the conflict using the required message: "Jest Doctor: Multiple configurations found". Likewise, when the final resolved patterns match zero test files, the CLI will emit "Jest Doctor: No tests found" along with the effective patterns being used.

This tool improves Jest by making configuration issues transparent, reducing the time developers spend troubleshooting, and providing actionable guidance before any test execution begins. With its non-destructive nature and focused diagnostics, jest --doctor becomes a reliable first step for debugging test setups, ultimately improving reliability and user confidence in Jest.

Example

Implement a jest --doctor CLI mode that resolves configuration exactly as a normal run would, but instead of executing tests prints diagnostics. Detect when a project has both a config file and a package.json jest entry and emit a clear warning. Detect when the resolved configuration would discover zero tests and emit a clear warning including the effective patterns. Exit with status 0 and never execute test suites.

Pitch

Diagnostic messages must start with 'Jest Doctor: Multiple configurations found' and 'Jest Doctor: No tests found'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions