-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathlcov-runner.int.test.ts
More file actions
88 lines (85 loc) · 2.51 KB
/
Copy pathlcov-runner.int.test.ts
File metadata and controls
88 lines (85 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
import { osAgnosticAuditOutputs } from '@code-pushup/test-utils';
import { lcovResultsToAuditOutputs } from './lcov-runner.js';
describe('lcovResultsToAuditOutputs', () => {
it('should correctly convert lcov results to AuditOutputs and prepend project paths', async () => {
/**
* The stats passed in the fixture are as follows
* Functions: 2 found, 2 covered (100% coverage)
* Branches: 10 found, 8 covered (80% coverage) - last value of BRDA
* Lines: 10 found, 7 covered (70% coverage) - merged into one issue with line range
*/
const results = await lcovResultsToAuditOutputs(
[
{
resultsPath: path.join(
fileURLToPath(path.dirname(import.meta.url)),
'..',
'..',
'..',
'..',
'mocks',
'single-record-lcov.info',
),
pathToProject: 'packages/cli',
},
],
['branch', 'function', 'line'],
);
expect(osAgnosticAuditOutputs(results)).toMatchSnapshot();
});
it('should correctly merge all lines for coverage', async () => {
const results = await lcovResultsToAuditOutputs(
[
{
resultsPath: path.join(
fileURLToPath(path.dirname(import.meta.url)),
'..',
'..',
'..',
'..',
'mocks',
'no-coverage-lcov.info',
),
pathToProject: 'packages/cli',
},
],
['line'],
);
expect(osAgnosticAuditOutputs(results)).toMatchSnapshot();
});
it('should correctly merge duplicate LCOV records from multiple files', async () => {
const results = await lcovResultsToAuditOutputs(
[
{
resultsPath: path.join(
fileURLToPath(path.dirname(import.meta.url)),
'..',
'..',
'..',
'..',
'mocks',
'single-record-lcov.info',
),
pathToProject: 'packages/cli',
},
{
resultsPath: path.join(
fileURLToPath(path.dirname(import.meta.url)),
'..',
'..',
'..',
'..',
'mocks',
'duplicate-record-lcov.info',
),
pathToProject: 'packages/cli',
},
],
['branch', 'function', 'line'],
);
expect(osAgnosticAuditOutputs(results)).toMatchSnapshot();
});
});