Skip to content

Commit fa40fe1

Browse files
committed
test(plugin-typescript): add e2e test
1 parent 33ab047 commit fa40fe1

File tree

3 files changed

+235
-3
lines changed

3 files changed

+235
-3
lines changed
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
{
2+
"categories": [
3+
{
4+
"refs": [
5+
{
6+
"plugin": "typescript",
7+
"slug": "problems",
8+
"type": "group",
9+
"weight": 1,
10+
},
11+
{
12+
"plugin": "typescript",
13+
"slug": "ts-configuration",
14+
"type": "group",
15+
"weight": 1,
16+
},
17+
{
18+
"plugin": "typescript",
19+
"slug": "miscellaneous",
20+
"type": "group",
21+
"weight": 1,
22+
},
23+
],
24+
"slug": "typescript-quality",
25+
"title": "Typescript",
26+
},
27+
],
28+
"packageName": "@code-pushup/core",
29+
"plugins": [
30+
{
31+
"audits": [
32+
{
33+
"description": "Errors that occur during parsing and lexing of TypeScript source code",
34+
"details": {
35+
"issues": [
36+
{
37+
"message": "TS1136: Property assignment expected.",
38+
"severity": "error",
39+
"source": {
40+
"file": "tmp/e2e/plugin-typescript-e2e/src/1-syntax-errors.ts",
41+
"position": {
42+
"startLine": 1,
43+
},
44+
},
45+
},
46+
],
47+
},
48+
"displayValue": "1 issue",
49+
"score": 0,
50+
"slug": "syntax-errors",
51+
"title": "Syntax errors",
52+
"value": 1,
53+
},
54+
{
55+
"description": "Errors that occur during type checking and type inference",
56+
"details": {
57+
"issues": [
58+
{
59+
"message": "TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.",
60+
"severity": "error",
61+
"source": {
62+
"file": "tmp/e2e/plugin-typescript-e2e/src/2-semantic-errors.ts",
63+
"position": {
64+
"startLine": 3,
65+
},
66+
},
67+
},
68+
{
69+
"message": "TS2322: Type 'null' is not assignable to type 'string'.",
70+
"severity": "error",
71+
"source": {
72+
"file": "tmp/e2e/plugin-typescript-e2e/src/2-semantic-errors.ts",
73+
"position": {
74+
"startLine": 7,
75+
},
76+
},
77+
},
78+
],
79+
},
80+
"displayValue": "2 issues",
81+
"score": 0,
82+
"slug": "semantic-errors",
83+
"title": "Semantic errors",
84+
"value": 2,
85+
},
86+
{
87+
"description": "Errors that occur during TypeScript language service operations",
88+
"details": {
89+
"issues": [
90+
{
91+
"message": "TS4112: This member cannot have an 'override' modifier because its containing class 'Standalone' does not extend another class.",
92+
"severity": "error",
93+
"source": {
94+
"file": "tmp/e2e/plugin-typescript-e2e/src/4-languale-service.ts",
95+
"position": {
96+
"startLine": 2,
97+
},
98+
},
99+
},
100+
],
101+
},
102+
"displayValue": "1 issue",
103+
"score": 0,
104+
"slug": "declaration-and-language-service-errors",
105+
"title": "Declaration and language service errors",
106+
"value": 1,
107+
},
108+
{
109+
"description": "Errors that occur during TypeScript internal operations",
110+
"details": {
111+
"issues": [],
112+
},
113+
"displayValue": "0 issues",
114+
"score": 1,
115+
"slug": "internal-errors",
116+
"title": "Internal errors",
117+
"value": 0,
118+
},
119+
{
120+
"description": "Errors that occur when parsing TypeScript configuration files",
121+
"details": {
122+
"issues": [
123+
{
124+
"message": "TS6059: File '/Users/michael_hladky/WebstormProjects/quality-metrics-cli/tmp/e2e/plugin-typescript-e2e/exclude/utils.ts' is not under 'rootDir' 'src'. 'rootDir' is expected to contain all source files.",
125+
"severity": "error",
126+
"source": {
127+
"file": "tmp/e2e/plugin-typescript-e2e/src/6-configuration-errors.ts",
128+
"position": {
129+
"startLine": 1,
130+
},
131+
},
132+
},
133+
],
134+
},
135+
"displayValue": "1 issue",
136+
"score": 0,
137+
"slug": "configuration-errors",
138+
"title": "Configuration errors",
139+
"value": 1,
140+
},
141+
{
142+
"description": "Errors related to no implicit any compiler option",
143+
"details": {
144+
"issues": [],
145+
},
146+
"displayValue": "0 issues",
147+
"score": 1,
148+
"slug": "no-implicit-any-errors",
149+
"title": "No implicit any errors",
150+
"value": 0,
151+
},
152+
{
153+
"description": "Errors that do not match any known TypeScript error code",
154+
"details": {
155+
"issues": [],
156+
},
157+
"displayValue": "0 issues",
158+
"score": 1,
159+
"slug": "unknown-codes",
160+
"title": "Unknown codes",
161+
"value": 0,
162+
},
163+
],
164+
"date": "2025-03-21T14:28:54.857Z",
165+
"description": "Official Code PushUp Typescript plugin.",
166+
"docsUrl": "https://www.npmjs.com/package/@code-pushup/typescript-plugin/",
167+
"duration": 2251,
168+
"groups": [
169+
{
170+
"description": "Syntax, semantic, and internal compiler errors are critical for identifying and preventing bugs.",
171+
"refs": [
172+
{
173+
"slug": "syntax-errors",
174+
"weight": 1,
175+
},
176+
{
177+
"slug": "semantic-errors",
178+
"weight": 1,
179+
},
180+
{
181+
"slug": "no-implicit-any-errors",
182+
"weight": 1,
183+
},
184+
],
185+
"slug": "problems",
186+
"title": "Problems",
187+
},
188+
{
189+
"description": "TypeScript configuration and options errors ensure correct project setup, reducing risks from misconfiguration.",
190+
"refs": [
191+
{
192+
"slug": "configuration-errors",
193+
"weight": 1,
194+
},
195+
],
196+
"slug": "ts-configuration",
197+
"title": "Configuration",
198+
},
199+
{
200+
"description": "Errors that do not bring any specific value to the developer, but are still useful to know.",
201+
"refs": [
202+
{
203+
"slug": "unknown-codes",
204+
"weight": 1,
205+
},
206+
{
207+
"slug": "internal-errors",
208+
"weight": 1,
209+
},
210+
{
211+
"slug": "declaration-and-language-service-errors",
212+
"weight": 1,
213+
},
214+
],
215+
"slug": "miscellaneous",
216+
"title": "Miscellaneous",
217+
},
218+
],
219+
"icon": "typescript",
220+
"packageName": "@code-pushup/typescript-plugin",
221+
"slug": "typescript",
222+
"title": "Typescript",
223+
"version": "0.57.0",
224+
},
225+
],
226+
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ describe('PLUGIN collect report with typescript-plugin NPM package', () => {
5757
expect(code).toBe(0);
5858
const cleanStdout = removeColorCodes(stdout);
5959

60-
// @TODO should be 1 test failing => /● NoImplicitAny\s+1/
61-
expect(cleanStdout).toMatch(/ Configuration-Errors\s+\d+/);
60+
expect(cleanStdout).toMatch(/ Semantic errors\s+\d+ issue/);
61+
expect(cleanStdout).toMatch(/ Configuration errors\s+\d+ issue/);
62+
expect(cleanStdout).toMatch(
63+
/ Declaration and language service errors\s+\d+ issue/,
64+
);
65+
expect(cleanStdout).toMatch(/ Syntax errors\s+\d+ issue/);
66+
expect(cleanStdout).toMatch(/ Internal errors\s+\d+ issue/);
67+
expect(cleanStdout).toMatch(/ No implicit any errors\s+\d+ issue/);
6268

6369
const reportJson = await readJsonFile<Report>(
6470
join(envRoot, outputDir, 'report.json'),

packages/plugin-typescript/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { TYPESCRIPT_PLUGIN_SLUG } from './lib/constants.js';
22
export { typescriptPlugin } from './lib/typescript-plugin.js';
3-
export { getCategories } from './lib/utils.js';
3+
export { getCategories, getCategoryRefsFromGroups } from './lib/utils.js';
44
export {
55
type TypescriptPluginConfig,
66
type TypescriptPluginOptions,

0 commit comments

Comments
 (0)