@wp-tester/results 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/streaming.d.ts +198 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +620 -0
- package/dist/streaming.js.map +1 -0
- package/dist/streaming.spec.d.ts +5 -0
- package/dist/streaming.spec.d.ts.map +1 -0
- package/dist/streaming.spec.js +217 -0
- package/dist/streaming.spec.js.map +1 -0
- package/dist/summary.d.ts +13 -0
- package/dist/summary.d.ts.map +1 -0
- package/dist/summary.js +40 -0
- package/dist/summary.js.map +1 -0
- package/dist/teamcity-parser.d.ts +70 -0
- package/dist/teamcity-parser.d.ts.map +1 -0
- package/dist/teamcity-parser.js +256 -0
- package/dist/teamcity-parser.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vitest-streaming-reporter.d.ts +67 -0
- package/dist/vitest-streaming-reporter.d.ts.map +1 -0
- package/dist/vitest-streaming-reporter.js +236 -0
- package/dist/vitest-streaming-reporter.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vitest Streaming Reporter
|
|
3
|
+
*
|
|
4
|
+
* A custom Vitest reporter that outputs test results in real-time
|
|
5
|
+
* using the StreamingReporter for uniform output formatting.
|
|
6
|
+
*/
|
|
7
|
+
import { StreamingReporter } from "./streaming.js";
|
|
8
|
+
/**
|
|
9
|
+
* Get the test state from a TestCase
|
|
10
|
+
*/
|
|
11
|
+
function getTestState(testCase) {
|
|
12
|
+
const result = testCase.result();
|
|
13
|
+
if (result.state === "passed")
|
|
14
|
+
return "passed";
|
|
15
|
+
if (result.state === "failed")
|
|
16
|
+
return "failed";
|
|
17
|
+
if (result.state === "skipped")
|
|
18
|
+
return "skipped";
|
|
19
|
+
return "pending";
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the test duration from a TestCase
|
|
23
|
+
*/
|
|
24
|
+
function getTestDuration(testCase) {
|
|
25
|
+
const diagnostic = testCase.diagnostic();
|
|
26
|
+
return diagnostic?.duration || 0;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get error message from a TestCase
|
|
30
|
+
*/
|
|
31
|
+
function getErrorInfo(testCase) {
|
|
32
|
+
const result = testCase.result();
|
|
33
|
+
if (result.state === "failed" && result.errors && result.errors.length > 0) {
|
|
34
|
+
const error = result.errors[0];
|
|
35
|
+
return {
|
|
36
|
+
message: error.message || String(error),
|
|
37
|
+
trace: error.stack,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the parent suite name
|
|
44
|
+
*/
|
|
45
|
+
function getSuiteName(testCase) {
|
|
46
|
+
const parent = testCase.parent;
|
|
47
|
+
if ("name" in parent && parent.name) {
|
|
48
|
+
return parent.name;
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the file ID from a test module
|
|
54
|
+
*/
|
|
55
|
+
function getFileId(testModule) {
|
|
56
|
+
return testModule.moduleId;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get the file name from a test module
|
|
60
|
+
*/
|
|
61
|
+
function getFileName(testModule) {
|
|
62
|
+
// Extract filename from the module path using platform-independent path separator
|
|
63
|
+
const parts = testModule.moduleId.split(/[/\\]/);
|
|
64
|
+
return parts[parts.length - 1] || testModule.moduleId;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the file ID from a test case by traversing to parent module
|
|
68
|
+
*/
|
|
69
|
+
function getFileIdFromTestCase(testCase) {
|
|
70
|
+
let current = testCase;
|
|
71
|
+
while (current && 'parent' in current) {
|
|
72
|
+
current = current.parent;
|
|
73
|
+
}
|
|
74
|
+
// At this point, current should be a TestModule
|
|
75
|
+
return current.moduleId;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get the file ID from a test suite by traversing to parent module
|
|
79
|
+
*/
|
|
80
|
+
function getFileIdFromTestSuite(testSuite) {
|
|
81
|
+
let current = testSuite;
|
|
82
|
+
while (current && 'parent' in current) {
|
|
83
|
+
current = current.parent;
|
|
84
|
+
}
|
|
85
|
+
// At this point, current should be a TestModule
|
|
86
|
+
return current.moduleId;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Custom Vitest reporter that streams test results in real-time
|
|
90
|
+
*/
|
|
91
|
+
export class VitestStreamingReporter {
|
|
92
|
+
constructor(toolName = "vitest", streamingReporter) {
|
|
93
|
+
this.vitest = null;
|
|
94
|
+
this.streaming = streamingReporter || new StreamingReporter();
|
|
95
|
+
this.toolName = toolName;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the underlying StreamingReporter for access to results
|
|
99
|
+
*/
|
|
100
|
+
getStreamingReporter() {
|
|
101
|
+
return this.streaming;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Called when vitest is initialized
|
|
105
|
+
*/
|
|
106
|
+
onInit(vitest) {
|
|
107
|
+
this.vitest = vitest;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Called when the test run starts
|
|
111
|
+
*/
|
|
112
|
+
onTestRunStart() {
|
|
113
|
+
this.streaming.onRunStart(this.toolName);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Called when the test run ends
|
|
117
|
+
*/
|
|
118
|
+
onTestRunEnd() {
|
|
119
|
+
this.streaming.onRunEnd();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Called when a test module is collected (file loaded)
|
|
123
|
+
* Emit file:start event to begin buffering for this file
|
|
124
|
+
*/
|
|
125
|
+
onTestModuleCollected(testModule) {
|
|
126
|
+
const fileId = getFileId(testModule);
|
|
127
|
+
const fileName = getFileName(testModule);
|
|
128
|
+
this.streaming.onEvent({
|
|
129
|
+
type: "file:start",
|
|
130
|
+
fileId,
|
|
131
|
+
fileName,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Called when a test module finishes
|
|
136
|
+
* Emit file:end event to flush the buffer for this file
|
|
137
|
+
*/
|
|
138
|
+
onTestModuleResult(testModule) {
|
|
139
|
+
const fileId = getFileId(testModule);
|
|
140
|
+
this.streaming.onEvent({
|
|
141
|
+
type: "file:end",
|
|
142
|
+
fileId,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Called when a test suite starts
|
|
147
|
+
*/
|
|
148
|
+
onTestSuiteReady(testSuite) {
|
|
149
|
+
const fileId = getFileIdFromTestSuite(testSuite);
|
|
150
|
+
this.streaming.onEvent({
|
|
151
|
+
type: "suite:start",
|
|
152
|
+
name: testSuite.name,
|
|
153
|
+
fileId,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Called when a test suite ends
|
|
158
|
+
*/
|
|
159
|
+
onTestSuiteResult(testSuite) {
|
|
160
|
+
const fileId = getFileIdFromTestSuite(testSuite);
|
|
161
|
+
this.streaming.onEvent({
|
|
162
|
+
type: "suite:end",
|
|
163
|
+
name: testSuite.name,
|
|
164
|
+
fileId,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Called when a test case is ready to run
|
|
169
|
+
*/
|
|
170
|
+
onTestCaseReady(testCase) {
|
|
171
|
+
const suiteName = getSuiteName(testCase);
|
|
172
|
+
const fileId = getFileIdFromTestCase(testCase);
|
|
173
|
+
this.streaming.onEvent({
|
|
174
|
+
type: "test:start",
|
|
175
|
+
name: testCase.name,
|
|
176
|
+
suiteName,
|
|
177
|
+
fileId,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Called when a test case finishes
|
|
182
|
+
*/
|
|
183
|
+
onTestCaseResult(testCase) {
|
|
184
|
+
const state = getTestState(testCase);
|
|
185
|
+
const duration = getTestDuration(testCase);
|
|
186
|
+
const suiteName = getSuiteName(testCase);
|
|
187
|
+
const fileId = getFileIdFromTestCase(testCase);
|
|
188
|
+
const { message, trace } = getErrorInfo(testCase);
|
|
189
|
+
switch (state) {
|
|
190
|
+
case "passed":
|
|
191
|
+
this.streaming.onEvent({
|
|
192
|
+
type: "test:pass",
|
|
193
|
+
name: testCase.name,
|
|
194
|
+
suiteName,
|
|
195
|
+
duration,
|
|
196
|
+
fileId,
|
|
197
|
+
});
|
|
198
|
+
break;
|
|
199
|
+
case "failed":
|
|
200
|
+
this.streaming.onEvent({
|
|
201
|
+
type: "test:fail",
|
|
202
|
+
name: testCase.name,
|
|
203
|
+
suiteName,
|
|
204
|
+
duration,
|
|
205
|
+
message,
|
|
206
|
+
trace,
|
|
207
|
+
fileId,
|
|
208
|
+
});
|
|
209
|
+
break;
|
|
210
|
+
case "skipped":
|
|
211
|
+
this.streaming.onEvent({
|
|
212
|
+
type: "test:skip",
|
|
213
|
+
name: testCase.name,
|
|
214
|
+
suiteName,
|
|
215
|
+
fileId,
|
|
216
|
+
});
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
this.streaming.onEvent({
|
|
220
|
+
type: "test:pending",
|
|
221
|
+
name: testCase.name,
|
|
222
|
+
suiteName,
|
|
223
|
+
fileId,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Create a streaming reporter factory function for use in Vitest config
|
|
230
|
+
* @param toolName - Name of the tool for the report
|
|
231
|
+
* @returns Reporter instance
|
|
232
|
+
*/
|
|
233
|
+
export function createVitestStreamingReporter(toolName = "vitest") {
|
|
234
|
+
return new VitestStreamingReporter(toolName);
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=vitest-streaming-reporter.js.map
|
|
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AAC;oBACrB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,SAAS;oBACT,MAAM;iBACP,CAAC,CAAC;gBACH,MAAM;YACR;gBACE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;oBACrB,IAAI,EAAE,cAAc;oBACpB,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,SAAS;oBACT,MAAM;iBACP,CAAC,CAAC;QACP,CAAC;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC3C,WAAmB,QAAQ;IAE3B,OAAO,IAAI,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-tester/results",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Test result types and formatting for wp-tester",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"type-check": "tsc --noEmit"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"ctrf": "^0.0.17"
|
|
28
|
+
"ctrf": "^0.0.17",
|
|
29
|
+
"picocolors": "^1.1.1",
|
|
30
|
+
"vitest": "^4.0.13"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
33
|
"@types/node": "^24.10.1",
|
|
32
34
|
"tsc-alias": "^1.8.16",
|
|
33
|
-
"typescript": "^5.9.3"
|
|
34
|
-
"vitest": "^4.0.13"
|
|
35
|
+
"typescript": "^5.9.3"
|
|
35
36
|
}
|
|
36
37
|
}
|