1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00
denoland-deno/tests/specs/test/clean_flag/main.js
Asher Gomez 71375491d1
feat(cli/test): deno test --clean (#23519)
The result of the call is ignored as it throws even when the directory
does not exist.

Closes #23491
2024-05-23 03:04:12 +00:00

23 lines
628 B
JavaScript

import { emptyDir } from "../../../util/std/fs/empty_dir.ts";
const DIR = "./coverage";
const COMMAND = new Deno.Command(Deno.execPath(), {
args: ["test", "--coverage", "--clean"],
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);