How to contributing

Thank you for your interest in contributing to jest-doctor

We welcome bug reports, documentation improvements, and code contributions. Because jest-doctor operates at a very low level of Jest’s runtime, contributions are expected to be careful, well-tested, and explicit about tradeoffs.

By participating in this project, you agree to be respectful and constructive in discussions and reviews.

Project philosophy

Most design decisions in this repo are guided by the following principles:

If a change weakens any of these guarantees, expect it to be discussed during review.

Repository structure

src/
  env/               # Custom Jest environments (node / jsdom)
  patch/             # Global API patches (timers, promises, console, it/test)
  utils/             # Shared helpers and leak-reporting utilities
  reporter.ts        # Jest reporter implementation
  createEnvMixin.ts  # mixin to create jest environments

e2e/
  fixtures/          # Jest projects used for end‑to‑end testing
  tests/             # E2E tests asserting real Jest behavior

docs/
  architecture.md    # How jest-doctor works internally
  motivation.md      # Why the project exists

If you are new to the project, start with architecture.

Getting started

Prerequisites

Installation

yarn install

Run end-to-end tests

yarn test:matrix

The command also supports two optional parameters the major jest version to test and a test file matcher pattern. For example to test jest 30 only fake-timer test:

yarn test:matrix 30 fake-timer

E2E tests execute real Jest runs using the fixtures in e2e/fixtures and are focused on case coverage. These tests are essential for validating behavior across environments and Jest versions. The readme.md gives more insights on how they work in the background.

Run unit tests

yarn test:unit

Those unit tests should compliment the E2E tests and can be used to extend coverage and test parts that are not part of a use case.

Merging coverage

yarn coverage:merge

This will merge both unit and E2E coverage into a single report which is stored inside coverage directory.

Development workflow

  1. Fork the repository
  2. Create a new branch from main
  3. Make focused, incremental changes
  4. Add or update tests
  5. Ensure all tests pass

Avoid mixing unrelated changes in a single PR.

Testing requirements

jest-doctor is test-heavy by design.

Unit tests

End-to-end tests

A PR that changes runtime behavior without tests is unlikely to be merged.

Style guidelines

Linting is enforced via ESLint.

Documentation

Documentation lives in docs/ and README.md.

Please update docs when you:

Submitting a pull request

Pull request checklist

Before opening a PR, make sure you have:

PR description guidelines

A good PR description includes:

Small, focused PRs are strongly preferred over large refactors.

Getting help

If you’re unsure about an approach:

Design discussion and questions are very welcome.


Thanks for contributing — every improvement makes flaky tests a little less powerful 💪