Skip to content

Commit 6a961c2

Browse files
AndriiSiutaAS
andauthored
test: improve test coverage for plugin-coverage (#1055)
Close #1054 This pull request improve test coverage (int, unit, e2e) for `plugin-coverage` --------- Co-authored-by: AS <ASiuta_ext@mapal-os.com>
1 parent 3500abc commit 6a961c2

File tree

7 files changed

+780
-5
lines changed

7 files changed

+780
-5
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
TN:
2+
SF:src\lib\utils.ts
3+
FN:2,formatReportScore
4+
FN:6,calcDuration
5+
FNF:2
6+
FNH:1
7+
FNDA:1,formatReportScore
8+
FNDA:6,calcDuration
9+
DA:1,1
10+
DA:2,1
11+
DA:3,0
12+
DA:4,0
13+
DA:5,1
14+
DA:6,1
15+
DA:7,1
16+
DA:8,1
17+
DA:9,1
18+
DA:10,1
19+
LF:10
20+
LH:8
21+
BRDA:1,0,0,6
22+
BRDA:1,1,0,5
23+
BRDA:2,4,0,1
24+
BRDA:4,5,0,17
25+
BRDA:5,6,0,4
26+
BRDA:6,7,0,13
27+
BRDA:6,10,0,1
28+
BRDA:7,11,0,3
29+
BRDA:10,12,0,12
30+
BRDA:10,13,0,1
31+
BRF:10
32+
BRH:9
33+
end_of_record

packages/plugin-coverage/src/lib/runner/lcov/__snapshots__/lcov-runner.int.test.ts.snap

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,191 @@ exports[`lcovResultsToAuditOutputs > should correctly merge all lines for covera
274274
},
275275
]
276276
`;
277+
278+
exports[`lcovResultsToAuditOutputs > should correctly merge duplicate LCOV records from multiple files 1`] = `
279+
[
280+
{
281+
"details": {
282+
"trees": [
283+
{
284+
"root": {
285+
"children": [
286+
{
287+
"children": [
288+
{
289+
"children": [
290+
{
291+
"children": [
292+
{
293+
"children": [
294+
{
295+
"name": "utils.ts",
296+
"values": {
297+
"coverage": 1,
298+
"missing": [],
299+
},
300+
},
301+
],
302+
"name": "lib",
303+
"values": {
304+
"coverage": 1,
305+
},
306+
},
307+
],
308+
"name": "src",
309+
"values": {
310+
"coverage": 1,
311+
},
312+
},
313+
],
314+
"name": "cli",
315+
"values": {
316+
"coverage": 1,
317+
},
318+
},
319+
],
320+
"name": "packages",
321+
"values": {
322+
"coverage": 1,
323+
},
324+
},
325+
],
326+
"name": ".",
327+
"values": {
328+
"coverage": 1,
329+
},
330+
},
331+
"title": "Branch coverage",
332+
"type": "coverage",
333+
},
334+
],
335+
},
336+
"displayValue": "100 %",
337+
"score": 1,
338+
"slug": "branch-coverage",
339+
"value": 100,
340+
},
341+
{
342+
"details": {
343+
"trees": [
344+
{
345+
"root": {
346+
"children": [
347+
{
348+
"children": [
349+
{
350+
"children": [
351+
{
352+
"children": [
353+
{
354+
"children": [
355+
{
356+
"name": "utils.ts",
357+
"values": {
358+
"coverage": 1,
359+
"missing": [],
360+
},
361+
},
362+
],
363+
"name": "lib",
364+
"values": {
365+
"coverage": 1,
366+
},
367+
},
368+
],
369+
"name": "src",
370+
"values": {
371+
"coverage": 1,
372+
},
373+
},
374+
],
375+
"name": "cli",
376+
"values": {
377+
"coverage": 1,
378+
},
379+
},
380+
],
381+
"name": "packages",
382+
"values": {
383+
"coverage": 1,
384+
},
385+
},
386+
],
387+
"name": ".",
388+
"values": {
389+
"coverage": 1,
390+
},
391+
},
392+
"title": "Function coverage",
393+
"type": "coverage",
394+
},
395+
],
396+
},
397+
"displayValue": "100 %",
398+
"score": 1,
399+
"slug": "function-coverage",
400+
"value": 100,
401+
},
402+
{
403+
"details": {
404+
"trees": [
405+
{
406+
"root": {
407+
"children": [
408+
{
409+
"children": [
410+
{
411+
"children": [
412+
{
413+
"children": [
414+
{
415+
"children": [
416+
{
417+
"name": "utils.ts",
418+
"values": {
419+
"coverage": 1,
420+
"missing": [],
421+
},
422+
},
423+
],
424+
"name": "lib",
425+
"values": {
426+
"coverage": 1,
427+
},
428+
},
429+
],
430+
"name": "src",
431+
"values": {
432+
"coverage": 1,
433+
},
434+
},
435+
],
436+
"name": "cli",
437+
"values": {
438+
"coverage": 1,
439+
},
440+
},
441+
],
442+
"name": "packages",
443+
"values": {
444+
"coverage": 1,
445+
},
446+
},
447+
],
448+
"name": ".",
449+
"values": {
450+
"coverage": 1,
451+
},
452+
},
453+
"title": "Line coverage",
454+
"type": "coverage",
455+
},
456+
],
457+
},
458+
"displayValue": "100 %",
459+
"score": 1,
460+
"slug": "line-coverage",
461+
"value": 100,
462+
},
463+
]
464+
`;

packages/plugin-coverage/src/lib/runner/lcov/lcov-runner.int.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,37 @@ describe('lcovResultsToAuditOutputs', () => {
5252
);
5353
expect(osAgnosticAuditOutputs(results)).toMatchSnapshot();
5454
});
55+
56+
it('should correctly merge duplicate LCOV records from multiple files', async () => {
57+
const results = await lcovResultsToAuditOutputs(
58+
[
59+
{
60+
resultsPath: path.join(
61+
fileURLToPath(path.dirname(import.meta.url)),
62+
'..',
63+
'..',
64+
'..',
65+
'..',
66+
'mocks',
67+
'single-record-lcov.info',
68+
),
69+
pathToProject: 'packages/cli',
70+
},
71+
{
72+
resultsPath: path.join(
73+
fileURLToPath(path.dirname(import.meta.url)),
74+
'..',
75+
'..',
76+
'..',
77+
'..',
78+
'mocks',
79+
'duplicate-record-lcov.info',
80+
),
81+
pathToProject: 'packages/cli',
82+
},
83+
],
84+
['branch', 'function', 'line'],
85+
);
86+
expect(osAgnosticAuditOutputs(results)).toMatchSnapshot();
87+
});
5588
});

0 commit comments

Comments
 (0)