betterer icon indicating copy to clipboard operation
betterer copied to clipboard

coverage() function does not work

Open piotrwalczak1 opened this issue 2 years ago • 1 comments
trafficstars

Describe the bug In spite of the fact that coverage file report is created using jest configuration, when running test for coverage from the docs it says:

Could not read coverage summary at readCoverageSummary
...
 at async BettererWorkerRunΩ.run

To Reproduce betterer.ts

import { coverage } from "@betterer/coverage";

export default {
  "increase per-file test coverage": () => coverage(),
};

Expected behavior Test should execute without errors

Screenshots* If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • OS: [Ubuntu 22.04]
  • Betterer Version [e.g. 1.0.2, cli 5.4.0]
  • Node Version [e.g. 18.*]

Additional context jest config:

module.exports = {
  preset: "ts-jest",
  testEnvironment: "node",
  testMatch: ["**/**/*test*.ts"],
  testPathIgnorePatterns: ["/node_modules/", "/coverage"],
  moduleFileExtensions: ["ts", "tsx", "js", "json"],
  verbose: true,
  transform: {
    "^.+\\.tsx?$": "ts-jest",
  },
  collectCoverage: true,
  collectCoverageFrom: ["**/lib/**/*.ts"],
  coveragePathIgnorePatterns: [
    "/node_modules/",
    "\\.d\\.ts$", // Ignore .d.ts files
  ],
};

piotrwalczak1 avatar Jul 04 '23 14:07 piotrwalczak1

Very sorry for not getting back to this, but on the off change you see it, just want to check:

  1. Have you set the Jest coverageDirectory for the output?
  2. Have you tried passing the actual output directory to the coverage test?
import { coverage } from "@betterer/coverage";

export default {
  "increase per-file test coverage": () => coverage('./my-reports-folder/my-report.json')
};

It defaults to './coverage/coverage-summary.json'. as you can see here.

Either way, thanks for reporting an issue, the docs here clearly need some more details!

phenomnomnominal avatar Sep 15 '24 14:09 phenomnomnominal