nicolo-ribaudo / jest-light-runner

A Jest runner that runs tests directly in bare Node.js, without virtualizing the environment.
MIT License
232 stars 24 forks source link

Expand documentation on coverage report setup #72

Open gomain opened 1 year ago

gomain commented 1 year ago

Please expand the coverage report section of the README to include minimal steps to set up coverage reporting. Such that people with lesser knowledge of babel and loaders can follow.

Included discussion was based on my personal experience. For context I use pnpm with workspaces via rush.

Discussed in https://github.com/nicolo-ribaudo/jest-light-runner/discussions/71#discussioncomment-5217946

So I'v finally got it working.

  1. Install "babel-register-esm", save dev
  2. In ./jest.config.mjs
    collectCoverage: true,
    coverageProvider: "babel",
    coverageReporters: ["text"],
  3. Add file ./babel.config.json
    {
      "plugins": ["babel-plugin-istanbul"]
    }
  4. Run tests with NODE_OPTIONS='--loader=babel-register-esm' jest babal-istanbul