betterer
betterer copied to clipboard
coverage() function does not work
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
],
};
Very sorry for not getting back to this, but on the off change you see it, just want to check:
- Have you set the Jest
coverageDirectoryfor the output? - Have you tried passing the actual output directory to the
coveragetest?
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!