1 |
|
2 |
|
3 | import { bold, green, red, yellow } from "kleur/colors";
|
4 | import { relative } from "path";
|
5 |
|
6 | import errorConsole from "./errorConsole.mjs";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export default function reportCoverage({
|
14 | filesCount,
|
15 | covered,
|
16 | ignored,
|
17 | uncovered,
|
18 | }) {
|
19 | if (covered.length) {
|
20 | console.group(
|
21 | `\n${green(
|
22 | `${covered.length} file${covered.length === 1 ? "" : "s"} covered:`
|
23 | )}\n`
|
24 | );
|
25 |
|
26 | for (const path of covered) console.info(relative("", path));
|
27 |
|
28 | console.groupEnd();
|
29 | }
|
30 |
|
31 | if (ignored.length) {
|
32 | console.group(
|
33 | `\n${yellow(
|
34 | `${ignored.length} file${
|
35 | ignored.length === 1 ? "" : "s"
|
36 | } ignoring coverage:`
|
37 | )}\n`
|
38 | );
|
39 |
|
40 | for (const { path, ranges } of ignored)
|
41 | for (const { start, end } of ranges)
|
42 | console.info(
|
43 | `${relative("", path)}:${start.line}:${start.column} → ${end.line}:${
|
44 | end.column
|
45 | }`
|
46 | );
|
47 |
|
48 | console.groupEnd();
|
49 | }
|
50 |
|
51 | if (uncovered.length) {
|
52 | errorConsole.group(
|
53 | `\n${red(
|
54 | `${uncovered.length} file${
|
55 | uncovered.length === 1 ? "" : "s"
|
56 | } missing coverage:`
|
57 | )}\n`
|
58 | );
|
59 |
|
60 | for (const { path, ranges } of uncovered)
|
61 | for (const { start, end } of ranges)
|
62 | errorConsole.info(
|
63 | `${relative("", path)}:${start.line}:${start.column} → ${end.line}:${
|
64 | end.column
|
65 | }`
|
66 | );
|
67 |
|
68 | errorConsole.groupEnd();
|
69 | }
|
70 |
|
71 | console.info(
|
72 | `\n${bold(
|
73 | (uncovered.length ? red : ignored.length ? yellow : green)(
|
74 | `${covered.length}/${filesCount} files covered.`
|
75 | )
|
76 | )}\n`
|
77 | );
|
78 | }
|