mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00

This PR updates the behavior of `deno test --coverage` option. Now if `--coverage` option is specified, `deno test` command automatically shows summary report in the terminal, and generates the lcov report in `$coverage_dir/lcov.info` and html report in `$coverage_dir/html/` This change also adds `--coverage-raw-data-only` flag, which prevents the above reports generated, instead only generates the raw json coverage data (which is the same as current behavior)
23 lines
640 B
JavaScript
23 lines
640 B
JavaScript
import { emptyDir } from "@std/fs/empty-dir";
|
|
|
|
const DIR = "./coverage";
|
|
const COMMAND = new Deno.Command(Deno.execPath(), {
|
|
args: ["test", "--coverage", "--clean", "--coverage-raw-data-only"],
|
|
stdout: "null",
|
|
});
|
|
|
|
async function getCoverageFiles() {
|
|
return await Array.fromAsync(Deno.readDir(DIR), ({ name }) => name);
|
|
}
|
|
|
|
await emptyDir(DIR);
|
|
await COMMAND.output();
|
|
const files1 = new Set(await getCoverageFiles());
|
|
|
|
await COMMAND.output();
|
|
const files2 = new Set(await getCoverageFiles());
|
|
|
|
console.log(files1.size === files2.size);
|
|
console.log(files1.intersection(files2).size === 0);
|
|
await emptyDir(DIR);
|
|
await Deno.remove(DIR);
|