Open jakeboone02 opened 3 weeks ago
I added this test locally to /test/cli/test/coverage.test.ts
to track it. If you remove the coverage = false
line or change it to coverage = true
, the test passes.
test("command line flag --coverage overrides bunfig", async () => {
const dir = tempDirWithFiles("cmd-line-overrides-bunfig", {
"cmd-line-overrides-bunfig.test.ts": `
import { covered } from "./cmd-line-overrides-bunfig";
test("cmd line overrides bunfig", () => {
expect(covered()).toBe(42);
});
`,
"cmd-line-overrides-bunfig.ts": `
export function covered() {
// this function IS covered
return 42;
}
export function uncovered() {
// this function is not covered
return 43;
}
`,
"bunfig.toml": `
[test]
coverage = false
`,
"package.json": JSON.stringify(
{
name: "cmd-line-overrides-bunfig",
version: "1.0.0",
},
null,
2,
),
});
const { stderr, exitCode } = Bun.spawnSync({
cmd: [bunExe(), "test", "cmd-line-overrides-bunfig.test.ts", "--coverage"],
cwd: dir,
env: bunEnv,
stderr: "pipe",
stdout: "pipe",
stdin: "inherit",
});
expect(stderr.toString().trim()).toContain("% Funcs");
expect(exitCode).toBe(0);
});
What version of Bun is running?
1.1.17+bb66bba1b
What platform is your computer?
Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
bunfig.toml:
index.js:
idx.test.js:
What is the expected behavior?
The
--coverage
flag on the command line should override thecoverage = false
configuration inbunfig.toml
, and coverage should be collected/reported.What do you see instead?
The
coverage
value configured inbunfig.toml
always takes precedence over the--coverage
command line flag. In the example above, coverage is not reported due to thecoverage = false
inbunfig.toml
.Additional information
I was starting to address #4346, but ran into this issue.