Skip to content

Commit 2dc1689

Browse files
committed
feat(plugin-coverage): replace issues with tree
1 parent f87b869 commit 2dc1689

File tree

14 files changed

+1024
-569
lines changed

14 files changed

+1024
-569
lines changed

e2e/plugin-coverage-e2e/tests/__snapshots__/collect.e2e.test.ts.snap

Lines changed: 349 additions & 108 deletions
Large diffs are not rendered by default.

e2e/plugin-coverage-e2e/tests/collect.e2e.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { cp } from 'node:fs/promises';
22
import path from 'node:path';
3+
import { simpleGit } from 'simple-git';
34
import { afterAll, afterEach, beforeAll } from 'vitest';
45
import { type Report, reportSchema } from '@code-pushup/models';
56
import { nxTargetProject } from '@code-pushup/test-nx-utils';
67
import {
78
E2E_ENVIRONMENTS_DIR,
89
TEST_OUTPUT_DIR,
10+
initGitRepo,
911
omitVariableReportData,
1012
teardownTestFolder,
1113
} from '@code-pushup/test-utils';
@@ -22,6 +24,8 @@ describe('PLUGIN collect report with coverage-plugin NPM package', () => {
2224

2325
beforeAll(async () => {
2426
await cp(fixtureDir, testFileDir, { recursive: true });
27+
await initGitRepo(simpleGit, { baseDir: basicDir });
28+
await initGitRepo(simpleGit, { baseDir: existingDir });
2529
});
2630

2731
afterAll(async () => {
@@ -34,24 +38,24 @@ describe('PLUGIN collect report with coverage-plugin NPM package', () => {
3438
await teardownTestFolder(path.join(existingDir, '.code-pushup'));
3539
});
3640

37-
it('should run Code coverage plugin which collects passed results and creates report.json', async () => {
41+
it('should run Code coverage plugin which runs tests and creates report.json', async () => {
3842
const { code } = await executeProcess({
3943
command: 'npx',
40-
args: ['@code-pushup/cli', 'collect', '--no-progress'],
44+
args: ['code-pushup', 'collect', '--no-progress'],
4145
cwd: basicDir,
4246
});
4347

4448
expect(code).toBe(0);
4549

46-
const report = await readJsonFile(
50+
const report = await readJsonFile<Report>(
4751
path.join(basicDir, '.code-pushup', 'report.json'),
4852
);
4953

5054
expect(() => reportSchema.parse(report)).not.toThrow();
51-
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
55+
expect(omitVariableReportData(report)).toMatchSnapshot();
5256
});
5357

54-
it('should run Code coverage plugin that runs coverage tool and creates report.json', async () => {
58+
it('should run Code coverage plugin which parses existing lcov report and creates report.json', async () => {
5559
const { code } = await executeProcess({
5660
command: 'npx',
5761
args: ['@code-pushup/cli', 'collect', '--no-progress'],
@@ -60,11 +64,11 @@ describe('PLUGIN collect report with coverage-plugin NPM package', () => {
6064

6165
expect(code).toBe(0);
6266

63-
const report = await readJsonFile(
67+
const report = await readJsonFile<Report>(
6468
path.join(existingDir, '.code-pushup', 'report.json'),
6569
);
6670

6771
expect(() => reportSchema.parse(report)).not.toThrow();
68-
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
72+
expect(omitVariableReportData(report)).toMatchSnapshot();
6973
});
7074
});

e2e/plugin-coverage-e2e/vite.config.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { defineConfig } from 'vite';
33
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
44

55
export default defineConfig({
6-
cacheDir: '../../node_modules/.vite/plugin-lighthouse-e2e',
6+
cacheDir: '../../node_modules/.vite/plugin-coverage-e2e',
77
test: {
88
reporters: ['basic'],
99
testTimeout: 40_000,

e2e/plugin-jsdocs-e2e/tests/__snapshots__/report.json renamed to e2e/plugin-jsdocs-e2e/tests/__snapshots__/collect.e2e.test.ts.snap

Lines changed: 122 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,46 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`PLUGIN collect report with jsdocs-plugin NPM package > should run JSDoc plugin for Angular example dir and create report.json 1`] = `
14
{
25
"packageName": "@code-pushup/core",
36
"plugins": [
47
{
5-
"title": "JSDoc coverage",
6-
"slug": "jsdocs",
7-
"icon": "folder-docs",
8-
"description": "Official Code PushUp JSDoc coverage plugin.",
9-
"docsUrl": "https://www.npmjs.com/package/@code-pushup/jsdocs-plugin/",
10-
"groups": [
11-
{
12-
"slug": "documentation-coverage",
13-
"refs": [
14-
{
15-
"slug": "classes-coverage",
16-
"weight": 2
17-
},
18-
{
19-
"slug": "methods-coverage",
20-
"weight": 2
21-
},
22-
{
23-
"slug": "functions-coverage",
24-
"weight": 2
25-
},
26-
{
27-
"slug": "interfaces-coverage",
28-
"weight": 1
29-
},
30-
{
31-
"slug": "variables-coverage",
32-
"weight": 1
33-
},
34-
{
35-
"slug": "properties-coverage",
36-
"weight": 1
37-
},
38-
{
39-
"slug": "types-coverage",
40-
"weight": 1
41-
},
42-
{
43-
"slug": "enums-coverage",
44-
"weight": 1
45-
}
46-
],
47-
"title": "Documentation coverage",
48-
"description": "Documentation coverage"
49-
}
50-
],
518
"audits": [
529
{
53-
"slug": "enums-coverage",
54-
"displayValue": "0 undocumented enums",
55-
"value": 0,
56-
"score": 1,
10+
"description": "Documentation coverage of enums",
5711
"details": {
58-
"issues": []
12+
"issues": [],
5913
},
14+
"displayValue": "0 undocumented enums",
15+
"score": 1,
16+
"slug": "enums-coverage",
6017
"title": "Enums coverage",
61-
"description": "Documentation coverage of enums"
18+
"value": 0,
6219
},
6320
{
64-
"slug": "interfaces-coverage",
65-
"displayValue": "0 undocumented interfaces",
66-
"value": 0,
67-
"score": 1,
21+
"description": "Documentation coverage of interfaces",
6822
"details": {
69-
"issues": []
23+
"issues": [],
7024
},
25+
"displayValue": "0 undocumented interfaces",
26+
"score": 1,
27+
"slug": "interfaces-coverage",
7128
"title": "Interfaces coverage",
72-
"description": "Documentation coverage of interfaces"
29+
"value": 0,
7330
},
7431
{
75-
"slug": "types-coverage",
76-
"displayValue": "0 undocumented types",
77-
"value": 0,
78-
"score": 1,
32+
"description": "Documentation coverage of types",
7933
"details": {
80-
"issues": []
34+
"issues": [],
8135
},
36+
"displayValue": "0 undocumented types",
37+
"score": 1,
38+
"slug": "types-coverage",
8239
"title": "Types coverage",
83-
"description": "Documentation coverage of types"
40+
"value": 0,
8441
},
8542
{
86-
"slug": "functions-coverage",
87-
"displayValue": "2 undocumented functions",
88-
"value": 2,
89-
"score": 0.3333,
43+
"description": "Documentation coverage of functions",
9044
"details": {
9145
"issues": [
9246
{
@@ -95,30 +49,30 @@
9549
"source": {
9650
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/app.component.spec.ts",
9751
"position": {
98-
"startLine": 1
99-
}
100-
}
52+
"startLine": 1,
53+
},
54+
},
10155
},
10256
{
10357
"message": "Missing functions documentation for mapEventToCustomEvent",
10458
"severity": "warning",
10559
"source": {
10660
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/map-event.function.ts",
10761
"position": {
108-
"startLine": 3
109-
}
110-
}
111-
}
112-
]
62+
"startLine": 3,
63+
},
64+
},
65+
},
66+
],
11367
},
68+
"displayValue": "2 undocumented functions",
69+
"score": 0.3333,
70+
"slug": "functions-coverage",
11471
"title": "Functions coverage",
115-
"description": "Documentation coverage of functions"
72+
"value": 2,
11673
},
11774
{
118-
"slug": "variables-coverage",
119-
"displayValue": "1 undocumented variables",
120-
"value": 1,
121-
"score": 0,
75+
"description": "Documentation coverage of variables",
12276
"details": {
12377
"issues": [
12478
{
@@ -127,31 +81,31 @@
12781
"source": {
12882
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/map-event.function.ts",
12983
"position": {
130-
"startLine": 1
131-
}
132-
}
133-
}
134-
]
84+
"startLine": 1,
85+
},
86+
},
87+
},
88+
],
13589
},
90+
"displayValue": "1 undocumented variables",
91+
"score": 0,
92+
"slug": "variables-coverage",
13693
"title": "Variables coverage",
137-
"description": "Documentation coverage of variables"
94+
"value": 1,
13895
},
13996
{
140-
"slug": "classes-coverage",
141-
"displayValue": "0 undocumented classes",
142-
"value": 0,
143-
"score": 1,
97+
"description": "Documentation coverage of classes",
14498
"details": {
145-
"issues": []
99+
"issues": [],
146100
},
101+
"displayValue": "0 undocumented classes",
102+
"score": 1,
103+
"slug": "classes-coverage",
147104
"title": "Classes coverage",
148-
"description": "Documentation coverage of classes"
105+
"value": 0,
149106
},
150107
{
151-
"slug": "methods-coverage",
152-
"displayValue": "1 undocumented methods",
153-
"value": 1,
154-
"score": 0.5,
108+
"description": "Documentation coverage of methods",
155109
"details": {
156110
"issues": [
157111
{
@@ -160,20 +114,20 @@
160114
"source": {
161115
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/app.component.ts",
162116
"position": {
163-
"startLine": 15
164-
}
165-
}
166-
}
167-
]
117+
"startLine": 15,
118+
},
119+
},
120+
},
121+
],
168122
},
123+
"displayValue": "1 undocumented methods",
124+
"score": 0.5,
125+
"slug": "methods-coverage",
169126
"title": "Methods coverage",
170-
"description": "Documentation coverage of methods"
127+
"value": 1,
171128
},
172129
{
173-
"slug": "properties-coverage",
174-
"displayValue": "1 undocumented properties",
175-
"value": 1,
176-
"score": 0,
130+
"description": "Documentation coverage of properties",
177131
"details": {
178132
"issues": [
179133
{
@@ -182,16 +136,66 @@
182136
"source": {
183137
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/app.component.ts",
184138
"position": {
185-
"startLine": 5
186-
}
187-
}
188-
}
189-
]
139+
"startLine": 5,
140+
},
141+
},
142+
},
143+
],
190144
},
145+
"displayValue": "1 undocumented properties",
146+
"score": 0,
147+
"slug": "properties-coverage",
191148
"title": "Properties coverage",
192-
"description": "Documentation coverage of properties"
193-
}
194-
]
195-
}
196-
]
197-
}
149+
"value": 1,
150+
},
151+
],
152+
"description": "Official Code PushUp JSDoc coverage plugin.",
153+
"docsUrl": "https://www.npmjs.com/package/@code-pushup/jsdocs-plugin/",
154+
"groups": [
155+
{
156+
"description": "Documentation coverage",
157+
"refs": [
158+
{
159+
"slug": "classes-coverage",
160+
"weight": 2,
161+
},
162+
{
163+
"slug": "methods-coverage",
164+
"weight": 2,
165+
},
166+
{
167+
"slug": "functions-coverage",
168+
"weight": 2,
169+
},
170+
{
171+
"slug": "interfaces-coverage",
172+
"weight": 1,
173+
},
174+
{
175+
"slug": "variables-coverage",
176+
"weight": 1,
177+
},
178+
{
179+
"slug": "properties-coverage",
180+
"weight": 1,
181+
},
182+
{
183+
"slug": "types-coverage",
184+
"weight": 1,
185+
},
186+
{
187+
"slug": "enums-coverage",
188+
"weight": 1,
189+
},
190+
],
191+
"slug": "documentation-coverage",
192+
"title": "Documentation coverage",
193+
},
194+
],
195+
"icon": "folder-docs",
196+
"slug": "jsdocs",
197+
"title": "JSDoc coverage",
198+
},
199+
],
200+
}
201+
`;

0 commit comments

Comments
 (0)