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