@rstest/core 0.5.1 → 0.5.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/LICENSE.md +270 -12
- package/dist/0~33.js +12 -6
- package/dist/0~655.js +3 -3
- package/dist/0~816.js +105 -52
- package/dist/0~85.js +0 -4
- package/dist/0~971.js +12 -6
- package/dist/index.js +1863 -32
- package/dist/worker.js +1786 -68
- package/dist-types/index.d.ts +80 -5
- package/dist-types/worker.d.ts +21 -8
- package/package.json +6 -3
- package/dist/0~223.js +0 -158
- package/dist/0~876.js +0 -771
- package/dist/0~908.js +0 -920
- package/dist/0~969.js +0 -1738
package/dist/0~876.js
DELETED
|
@@ -1,771 +0,0 @@
|
|
|
1
|
-
import 'module';
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import { stripVTControlCharacters } from "node:util";
|
|
4
|
-
export const __webpack_id__ = "876";
|
|
5
|
-
export const __webpack_ids__ = [
|
|
6
|
-
"876"
|
|
7
|
-
];
|
|
8
|
-
export const __webpack_modules__ = {
|
|
9
|
-
"./src/core/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
10
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
11
|
-
createRstest: ()=>createRstest
|
|
12
|
-
});
|
|
13
|
-
var external_node_fs_ = __webpack_require__("node:fs");
|
|
14
|
-
var manager = __webpack_require__("../../node_modules/.pnpm/@vitest+snapshot@3.2.4/node_modules/@vitest/snapshot/dist/manager.js");
|
|
15
|
-
var pathe_M_eThtNZ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
|
|
16
|
-
var dist = __webpack_require__("../../node_modules/.pnpm/std-env@3.9.0/node_modules/std-env/dist/index.mjs");
|
|
17
|
-
var src_config = __webpack_require__("./src/config.ts");
|
|
18
|
-
var stack_trace_parser_esm = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
|
|
19
|
-
var utils = __webpack_require__("./src/utils/index.ts");
|
|
20
|
-
const DEFAULT_RENDER_INTERVAL_MS = 1000;
|
|
21
|
-
const ESC = '\x1B[';
|
|
22
|
-
const CLEAR_LINE = `${ESC}K`;
|
|
23
|
-
const MOVE_CURSOR_ONE_ROW_UP = `${ESC}1A`;
|
|
24
|
-
const SYNC_START = `${ESC}?2026h`;
|
|
25
|
-
const SYNC_END = `${ESC}?2026l`;
|
|
26
|
-
class WindowRenderer {
|
|
27
|
-
options;
|
|
28
|
-
streams;
|
|
29
|
-
buffer = [];
|
|
30
|
-
renderInterval = void 0;
|
|
31
|
-
renderScheduled = false;
|
|
32
|
-
windowHeight = 0;
|
|
33
|
-
finished = false;
|
|
34
|
-
cleanups = [];
|
|
35
|
-
constructor(options){
|
|
36
|
-
this.options = {
|
|
37
|
-
interval: DEFAULT_RENDER_INTERVAL_MS,
|
|
38
|
-
...options
|
|
39
|
-
};
|
|
40
|
-
this.streams = {
|
|
41
|
-
output: options.logger.outputStream.write.bind(options.logger.outputStream),
|
|
42
|
-
error: options.logger.errorStream.write.bind(options.logger.errorStream)
|
|
43
|
-
};
|
|
44
|
-
this.cleanups.push(this.interceptStream(process.stdout, 'output'), this.interceptStream(process.stderr, 'error'));
|
|
45
|
-
this.start();
|
|
46
|
-
}
|
|
47
|
-
start() {
|
|
48
|
-
this.finished = false;
|
|
49
|
-
this.renderInterval = setInterval(()=>this.schedule(), this.options.interval).unref();
|
|
50
|
-
}
|
|
51
|
-
stop() {
|
|
52
|
-
this.cleanups.splice(0).map((fn)=>fn());
|
|
53
|
-
clearInterval(this.renderInterval);
|
|
54
|
-
}
|
|
55
|
-
finish() {
|
|
56
|
-
this.finished = true;
|
|
57
|
-
this.flushBuffer();
|
|
58
|
-
clearInterval(this.renderInterval);
|
|
59
|
-
}
|
|
60
|
-
schedule() {
|
|
61
|
-
if (!this.renderScheduled) {
|
|
62
|
-
this.renderScheduled = true;
|
|
63
|
-
this.flushBuffer();
|
|
64
|
-
setTimeout(()=>{
|
|
65
|
-
this.renderScheduled = false;
|
|
66
|
-
}, 100).unref();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
flushBuffer() {
|
|
70
|
-
if (0 === this.buffer.length) return this.render();
|
|
71
|
-
let current;
|
|
72
|
-
for (const next of this.buffer.splice(0)){
|
|
73
|
-
if (!current) {
|
|
74
|
-
current = next;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (current.type !== next.type) {
|
|
78
|
-
this.render(current.message, current.type);
|
|
79
|
-
current = next;
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
current.message += next.message;
|
|
83
|
-
}
|
|
84
|
-
if (current) this.render(current?.message, current?.type);
|
|
85
|
-
}
|
|
86
|
-
render(message, type = 'output') {
|
|
87
|
-
if (this.finished) {
|
|
88
|
-
this.clearWindow();
|
|
89
|
-
return this.write(message || '', type);
|
|
90
|
-
}
|
|
91
|
-
const windowContent = this.options.getWindow();
|
|
92
|
-
const rowCount = getRenderedRowCount(windowContent, this.options.logger.getColumns());
|
|
93
|
-
let padding = this.windowHeight - rowCount;
|
|
94
|
-
if (padding > 0 && message) padding -= getRenderedRowCount([
|
|
95
|
-
message
|
|
96
|
-
], this.options.logger.getColumns());
|
|
97
|
-
this.write(SYNC_START);
|
|
98
|
-
this.clearWindow();
|
|
99
|
-
if (message) this.write(message, type);
|
|
100
|
-
if (padding > 0) this.write('\n'.repeat(padding));
|
|
101
|
-
this.write(windowContent.join('\n'));
|
|
102
|
-
this.write(SYNC_END);
|
|
103
|
-
this.windowHeight = rowCount + Math.max(0, padding);
|
|
104
|
-
}
|
|
105
|
-
clearWindow() {
|
|
106
|
-
if (0 === this.windowHeight) return;
|
|
107
|
-
this.write(CLEAR_LINE);
|
|
108
|
-
for(let i = 1; i < this.windowHeight; i++)this.write(`${MOVE_CURSOR_ONE_ROW_UP}${CLEAR_LINE}`);
|
|
109
|
-
this.windowHeight = 0;
|
|
110
|
-
}
|
|
111
|
-
interceptStream(stream, type) {
|
|
112
|
-
const original = stream.write.bind(stream);
|
|
113
|
-
stream.write = (chunk, _, callback)=>{
|
|
114
|
-
if (chunk) if (this.finished) this.write(chunk.toString(), type);
|
|
115
|
-
else this.buffer.push({
|
|
116
|
-
type,
|
|
117
|
-
message: chunk.toString()
|
|
118
|
-
});
|
|
119
|
-
callback?.();
|
|
120
|
-
};
|
|
121
|
-
return function restore() {
|
|
122
|
-
stream.write = original;
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
write(message, type = 'output') {
|
|
126
|
-
this.streams[type](message);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function getRenderedRowCount(rows, columns) {
|
|
130
|
-
let count = 0;
|
|
131
|
-
for (const row of rows){
|
|
132
|
-
const text = stripVTControlCharacters(row);
|
|
133
|
-
count += Math.max(1, Math.ceil(text.length / columns));
|
|
134
|
-
}
|
|
135
|
-
return count;
|
|
136
|
-
}
|
|
137
|
-
class StatusRenderer {
|
|
138
|
-
rootPath;
|
|
139
|
-
renderer;
|
|
140
|
-
runningModules = new Set();
|
|
141
|
-
constructor(rootPath){
|
|
142
|
-
this.rootPath = rootPath;
|
|
143
|
-
this.renderer = new WindowRenderer({
|
|
144
|
-
getWindow: ()=>this.getContent(),
|
|
145
|
-
logger: {
|
|
146
|
-
outputStream: process.stdout,
|
|
147
|
-
errorStream: process.stderr,
|
|
148
|
-
getColumns: ()=>'columns' in process.stdout ? process.stdout.columns : 80
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
getContent() {
|
|
153
|
-
const summary = [];
|
|
154
|
-
for (const module of this.runningModules){
|
|
155
|
-
const relativePath = (0, pathe_M_eThtNZ.b)(this.rootPath, module);
|
|
156
|
-
summary.push(`${utils.yW.bgYellow(utils.yW.bold(' RUNS '))} ${(0, utils.EQ)(relativePath)}`);
|
|
157
|
-
}
|
|
158
|
-
summary.push('');
|
|
159
|
-
return summary;
|
|
160
|
-
}
|
|
161
|
-
addRunningModule(testPath) {
|
|
162
|
-
this.runningModules.add(testPath);
|
|
163
|
-
this.renderer?.schedule();
|
|
164
|
-
}
|
|
165
|
-
removeRunningModule(testPath) {
|
|
166
|
-
this.runningModules.delete(testPath);
|
|
167
|
-
this.renderer?.schedule();
|
|
168
|
-
}
|
|
169
|
-
clear() {
|
|
170
|
-
this.runningModules.clear();
|
|
171
|
-
this.renderer?.finish();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
var pathe_dist = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs");
|
|
175
|
-
const getSummaryStatusString = (tasks, name = 'tests', showTotal = true)=>{
|
|
176
|
-
if (0 === tasks.length) return utils.yW.dim(`no ${name}`);
|
|
177
|
-
const passed = tasks.filter((result)=>'pass' === result.status);
|
|
178
|
-
const failed = tasks.filter((result)=>'fail' === result.status);
|
|
179
|
-
const skipped = tasks.filter((result)=>'skip' === result.status);
|
|
180
|
-
const todo = tasks.filter((result)=>'todo' === result.status);
|
|
181
|
-
const status = [
|
|
182
|
-
failed.length ? utils.yW.bold(utils.yW.red(`${failed.length} failed`)) : null,
|
|
183
|
-
passed.length ? utils.yW.bold(utils.yW.green(`${passed.length} passed`)) : null,
|
|
184
|
-
skipped.length ? utils.yW.yellow(`${skipped.length} skipped`) : null,
|
|
185
|
-
todo.length ? utils.yW.gray(`${todo.length} todo`) : null
|
|
186
|
-
].filter(Boolean);
|
|
187
|
-
return status.join(utils.yW.dim(' | ')) + (showTotal && status.length > 1 ? utils.yW.gray(` (${tasks.length})`) : '');
|
|
188
|
-
};
|
|
189
|
-
const printSnapshotSummaryLog = (snapshots, rootDir)=>{
|
|
190
|
-
const summary = [];
|
|
191
|
-
if (snapshots.added) summary.push(utils.yW.bold(utils.yW.green(`${snapshots.added} written`)));
|
|
192
|
-
if (snapshots.unmatched) summary.push(utils.yW.bold(utils.yW.red(`${snapshots.unmatched} failed`)));
|
|
193
|
-
if (snapshots.updated) summary.push(utils.yW.bold(utils.yW.green(`${snapshots.updated} updated `)));
|
|
194
|
-
if (snapshots.filesRemoved) if (snapshots.didUpdate) summary.push(utils.yW.bold(utils.yW.green(`${snapshots.filesRemoved} files removed `)));
|
|
195
|
-
else summary.push(utils.yW.bold(utils.yW.yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
196
|
-
const POINTER = '➜';
|
|
197
|
-
if (snapshots.filesRemovedList?.length) {
|
|
198
|
-
const [head, ...tail] = snapshots.filesRemovedList;
|
|
199
|
-
summary.push(`${utils.yW.gray(POINTER)} ${(0, utils.XJ)(rootDir, head)}`);
|
|
200
|
-
for (const key of tail)summary.push(` ${(0, utils.XJ)(rootDir, key)}`);
|
|
201
|
-
}
|
|
202
|
-
if (snapshots.unchecked) {
|
|
203
|
-
if (snapshots.didUpdate) summary.push(utils.yW.bold(utils.yW.green(`${snapshots.unchecked} removed`)));
|
|
204
|
-
else summary.push(utils.yW.bold(utils.yW.yellow(`${snapshots.unchecked} obsolete`)));
|
|
205
|
-
for (const uncheckedFile of snapshots.uncheckedKeysByFile){
|
|
206
|
-
summary.push(`${utils.yW.gray(POINTER)} ${(0, utils.XJ)(rootDir, uncheckedFile.filePath)}`);
|
|
207
|
-
for (const key of uncheckedFile.keys)summary.push(` ${key}`);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
for (const [index, snapshot] of summary.entries()){
|
|
211
|
-
const title = 0 === index ? 'Snapshots' : '';
|
|
212
|
-
utils.vF.log(`${utils.yW.gray(title.padStart(12))} ${snapshot}`);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
const printSummaryLog = ({ results, testResults, snapshotSummary, duration, rootPath })=>{
|
|
216
|
-
utils.vF.log('');
|
|
217
|
-
printSnapshotSummaryLog(snapshotSummary, rootPath);
|
|
218
|
-
utils.vF.log(`${utils.yW.gray('Test Files'.padStart(11))} ${getSummaryStatusString(results)}`);
|
|
219
|
-
utils.vF.log(`${utils.yW.gray('Tests'.padStart(11))} ${getSummaryStatusString(testResults)}`);
|
|
220
|
-
utils.vF.log(`${utils.yW.gray('Duration'.padStart(11))} ${(0, utils.kV)(duration.totalTime)} ${utils.yW.gray(`(build ${(0, utils.kV)(duration.buildTime)}, tests ${(0, utils.kV)(duration.testTime)})`)}`);
|
|
221
|
-
utils.vF.log('');
|
|
222
|
-
};
|
|
223
|
-
const printSummaryErrorLogs = async ({ testResults, results, rootPath, getSourcemap, filterRerunTestPaths })=>{
|
|
224
|
-
const failedTests = [
|
|
225
|
-
...results.filter((i)=>'fail' === i.status && i.errors?.length && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true)),
|
|
226
|
-
...testResults.filter((i)=>'fail' === i.status && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true))
|
|
227
|
-
];
|
|
228
|
-
if (0 === failedTests.length) return;
|
|
229
|
-
utils.vF.log('');
|
|
230
|
-
utils.vF.log(utils.yW.bold('Summary of all failing tests:'));
|
|
231
|
-
utils.vF.log('');
|
|
232
|
-
for (const test of failedTests){
|
|
233
|
-
const relativePath = pathe_dist.Ay.relative(rootPath, test.testPath);
|
|
234
|
-
const nameStr = (0, utils.fN)(test);
|
|
235
|
-
utils.vF.log(`${utils.yW.bgRed(' FAIL ')} ${(0, utils.EQ)(relativePath)} ${nameStr.length ? `${utils.yW.dim(utils.vO)} ${nameStr}` : ''}`);
|
|
236
|
-
if (test.errors) {
|
|
237
|
-
const { printError } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "./src/utils/error.ts"));
|
|
238
|
-
for (const error of test.errors)await printError(error, getSourcemap, rootPath);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
const statusStr = {
|
|
243
|
-
fail: '✗',
|
|
244
|
-
pass: '✓',
|
|
245
|
-
todo: '-',
|
|
246
|
-
skip: '-'
|
|
247
|
-
};
|
|
248
|
-
const statusColorfulStr = {
|
|
249
|
-
fail: utils.yW.red(statusStr.fail),
|
|
250
|
-
pass: utils.yW.green(statusStr.pass),
|
|
251
|
-
todo: utils.yW.gray(statusStr.todo),
|
|
252
|
-
skip: utils.yW.gray(statusStr.skip)
|
|
253
|
-
};
|
|
254
|
-
const logCase = (result, slowTestThreshold)=>{
|
|
255
|
-
const isSlowCase = (result.duration || 0) > slowTestThreshold;
|
|
256
|
-
const icon = isSlowCase && 'pass' === result.status ? utils.yW.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
|
|
257
|
-
const nameStr = (0, utils.fN)(result);
|
|
258
|
-
const duration = void 0 !== result.duration ? ` (${(0, utils.kV)(result.duration)})` : '';
|
|
259
|
-
const retry = result.retryCount ? utils.yW.yellow(` (retry x${result.retryCount})`) : '';
|
|
260
|
-
utils.vF.log(` ${icon} ${nameStr}${utils.yW.gray(duration)}${retry}`);
|
|
261
|
-
if (result.errors) for (const error of result.errors)console.error(utils.yW.red(` ${error.message}`));
|
|
262
|
-
};
|
|
263
|
-
const logFileTitle = (test, relativePath, slowTestThreshold, alwaysShowTime = false)=>{
|
|
264
|
-
let title = ` ${utils.yW.bold(statusColorfulStr[test.status])} ${(0, utils.EQ)(relativePath)}`;
|
|
265
|
-
const formatDuration = (duration)=>utils.yW[duration > slowTestThreshold ? 'yellow' : 'green']((0, utils.kV)(duration));
|
|
266
|
-
title += ` ${utils.yW.gray(`(${test.results.length})`)}`;
|
|
267
|
-
const isTooSlow = test.duration && test.duration > slowTestThreshold;
|
|
268
|
-
if (alwaysShowTime || isTooSlow) title += ` ${formatDuration(test.duration)}`;
|
|
269
|
-
utils.vF.log(title);
|
|
270
|
-
};
|
|
271
|
-
class DefaultReporter {
|
|
272
|
-
rootPath;
|
|
273
|
-
config;
|
|
274
|
-
options = {};
|
|
275
|
-
statusRenderer;
|
|
276
|
-
constructor({ rootPath, options, config }){
|
|
277
|
-
this.rootPath = rootPath;
|
|
278
|
-
this.config = config;
|
|
279
|
-
this.options = options;
|
|
280
|
-
if (!dist.JO) this.statusRenderer = new StatusRenderer(rootPath);
|
|
281
|
-
}
|
|
282
|
-
onTestFileStart(test) {
|
|
283
|
-
this.statusRenderer?.addRunningModule(test.testPath);
|
|
284
|
-
}
|
|
285
|
-
onTestFileResult(test) {
|
|
286
|
-
this.statusRenderer?.removeRunningModule(test.testPath);
|
|
287
|
-
const relativePath = (0, pathe_M_eThtNZ.b)(this.rootPath, test.testPath);
|
|
288
|
-
const { slowTestThreshold } = this.config;
|
|
289
|
-
logFileTitle(test, relativePath, slowTestThreshold);
|
|
290
|
-
const isTooSlow = test.duration && test.duration > slowTestThreshold;
|
|
291
|
-
const hasRetryCase = test.results.some((result)=>(result.retryCount || 0) > 0);
|
|
292
|
-
if ('fail' !== test.status && !isTooSlow && !hasRetryCase) return;
|
|
293
|
-
const showAllCases = isTooSlow && !test.results.some((result)=>(result.duration || 0) > slowTestThreshold);
|
|
294
|
-
for (const result of test.results){
|
|
295
|
-
const isSlowCase = (result.duration || 0) > slowTestThreshold;
|
|
296
|
-
const retried = (result.retryCount || 0) > 0;
|
|
297
|
-
if (showAllCases || 'fail' === result.status || isSlowCase || retried) logCase(result, slowTestThreshold);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
onTestCaseResult(_result) {}
|
|
301
|
-
onUserConsoleLog(log) {
|
|
302
|
-
const shouldLog = this.config.onConsoleLog?.(log.content) ?? true;
|
|
303
|
-
if (!shouldLog) return;
|
|
304
|
-
const titles = [
|
|
305
|
-
log.name
|
|
306
|
-
];
|
|
307
|
-
const testPath = (0, pathe_M_eThtNZ.b)(this.rootPath, log.testPath);
|
|
308
|
-
if (log.trace) {
|
|
309
|
-
const [frame] = (0, stack_trace_parser_esm.q)(log.trace);
|
|
310
|
-
const filePath = (0, pathe_M_eThtNZ.b)(this.rootPath, frame.file || '');
|
|
311
|
-
if (filePath !== testPath) titles.push((0, utils.EQ)(testPath));
|
|
312
|
-
titles.push((0, utils.EQ)(filePath) + utils.yW.gray(`:${frame.lineNumber}:${frame.column}`));
|
|
313
|
-
} else titles.push((0, utils.EQ)(testPath));
|
|
314
|
-
utils.vF.log(titles.join(utils.yW.gray(' | ')));
|
|
315
|
-
utils.vF.log(log.content);
|
|
316
|
-
utils.vF.log('');
|
|
317
|
-
}
|
|
318
|
-
async onExit() {
|
|
319
|
-
this.statusRenderer?.clear();
|
|
320
|
-
}
|
|
321
|
-
async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths }) {
|
|
322
|
-
this.statusRenderer?.clear();
|
|
323
|
-
if (false === this.options.summary) return;
|
|
324
|
-
await printSummaryErrorLogs({
|
|
325
|
-
testResults,
|
|
326
|
-
results,
|
|
327
|
-
rootPath: this.rootPath,
|
|
328
|
-
getSourcemap,
|
|
329
|
-
filterRerunTestPaths
|
|
330
|
-
});
|
|
331
|
-
printSummaryLog({
|
|
332
|
-
results,
|
|
333
|
-
testResults,
|
|
334
|
-
duration,
|
|
335
|
-
rootPath: this.rootPath,
|
|
336
|
-
snapshotSummary
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
class GithubActionsReporter {
|
|
341
|
-
onWritePath;
|
|
342
|
-
rootPath;
|
|
343
|
-
constructor({ options, rootPath }){
|
|
344
|
-
this.onWritePath = options.onWritePath;
|
|
345
|
-
this.rootPath = rootPath;
|
|
346
|
-
}
|
|
347
|
-
log(message) {
|
|
348
|
-
console.log(`${message}\n`);
|
|
349
|
-
}
|
|
350
|
-
async onTestRunEnd({ results, testResults, getSourcemap }) {
|
|
351
|
-
const failedTests = [
|
|
352
|
-
...results.filter((i)=>'fail' === i.status && i.errors?.length),
|
|
353
|
-
...testResults.filter((i)=>'fail' === i.status)
|
|
354
|
-
];
|
|
355
|
-
if (0 === failedTests.length) return;
|
|
356
|
-
const { parseErrorStacktrace } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "./src/utils/error.ts"));
|
|
357
|
-
const logs = [];
|
|
358
|
-
for (const test of failedTests){
|
|
359
|
-
const { testPath } = test;
|
|
360
|
-
const nameStr = (0, utils.fN)(test);
|
|
361
|
-
const shortPath = (0, pathe_M_eThtNZ.b)(this.rootPath, testPath);
|
|
362
|
-
const title = `${shortPath} ${utils.vO} ${nameStr}`;
|
|
363
|
-
for (const error of test.errors || []){
|
|
364
|
-
let file = testPath;
|
|
365
|
-
let line = 1;
|
|
366
|
-
let column = 1;
|
|
367
|
-
const message = `${error.message}${error.diff ? `\n${error.diff}` : ''}`;
|
|
368
|
-
const type = 'error';
|
|
369
|
-
if (error.stack) {
|
|
370
|
-
const stackFrames = await parseErrorStacktrace({
|
|
371
|
-
stack: error.stack,
|
|
372
|
-
fullStack: error.fullStack,
|
|
373
|
-
getSourcemap
|
|
374
|
-
});
|
|
375
|
-
if (stackFrames[0]) {
|
|
376
|
-
file = stackFrames[0].file || test.testPath;
|
|
377
|
-
line = stackFrames[0].lineNumber || 1;
|
|
378
|
-
column = stackFrames[0].column || 1;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
logs.push(`::${type} file=${this.onWritePath?.(file) || file},line=${line},col=${column},title=${escapeData(title)}::${escapeData(message)}`);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
this.log('::group::error for github actions');
|
|
385
|
-
for (const log of logs)this.log(log);
|
|
386
|
-
this.log('::endgroup::');
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
function escapeData(s) {
|
|
390
|
-
return s.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/:/g, '%3A').replace(/,/g, '%2C');
|
|
391
|
-
}
|
|
392
|
-
var promises_ = __webpack_require__("node:fs/promises");
|
|
393
|
-
var strip_ansi = __webpack_require__("../../node_modules/.pnpm/strip-ansi@7.1.2/node_modules/strip-ansi/index.js");
|
|
394
|
-
var utils_error = __webpack_require__("./src/utils/error.ts");
|
|
395
|
-
class JUnitReporter {
|
|
396
|
-
rootPath;
|
|
397
|
-
outputPath;
|
|
398
|
-
constructor({ rootPath, options: { outputPath } = {} }){
|
|
399
|
-
this.rootPath = rootPath;
|
|
400
|
-
this.outputPath = outputPath;
|
|
401
|
-
}
|
|
402
|
-
sanitizeXml(text) {
|
|
403
|
-
let result = '';
|
|
404
|
-
for (const ch of (0, strip_ansi.A)(text)){
|
|
405
|
-
const cp = ch.codePointAt(0);
|
|
406
|
-
const valid = 0x09 === cp || 0x0a === cp || 0x0d === cp || cp >= 0x20 && cp <= 0xd7ff || cp >= 0xe000 && cp <= 0xfffd || cp >= 0x10000 && cp <= 0x10ffff;
|
|
407
|
-
if (valid) result += ch;
|
|
408
|
-
}
|
|
409
|
-
return result;
|
|
410
|
-
}
|
|
411
|
-
escapeXml(text) {
|
|
412
|
-
const sanitized = this.sanitizeXml(text);
|
|
413
|
-
return sanitized.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
414
|
-
}
|
|
415
|
-
async createJUnitTestCase(test, getSourcemap) {
|
|
416
|
-
const testCase = {
|
|
417
|
-
name: (0, utils.fN)(test),
|
|
418
|
-
classname: (0, pathe_M_eThtNZ.b)(this.rootPath, test.testPath),
|
|
419
|
-
time: (test.duration || 0) / 1000,
|
|
420
|
-
status: test.status
|
|
421
|
-
};
|
|
422
|
-
if (test.errors && test.errors.length > 0) testCase.errors = await Promise.all(test.errors.map(async (error)=>{
|
|
423
|
-
let details = `${error.message}${error.diff ? `\n${error.diff}` : ''}`;
|
|
424
|
-
const stackFrames = error.stack ? await (0, utils_error.parseErrorStacktrace)({
|
|
425
|
-
stack: error.stack,
|
|
426
|
-
fullStack: error.fullStack,
|
|
427
|
-
getSourcemap
|
|
428
|
-
}) : [];
|
|
429
|
-
if (stackFrames[0]) details += `\n${(0, utils_error.C)(stackFrames[0], this.rootPath)}`;
|
|
430
|
-
return {
|
|
431
|
-
message: this.escapeXml(error.message),
|
|
432
|
-
type: error.name || 'Error',
|
|
433
|
-
details: this.escapeXml(details)
|
|
434
|
-
};
|
|
435
|
-
}));
|
|
436
|
-
return testCase;
|
|
437
|
-
}
|
|
438
|
-
async createJUnitTestSuite(fileResult, getSourcemap) {
|
|
439
|
-
const testCases = await Promise.all(fileResult.results.map(async (test)=>this.createJUnitTestCase(test, getSourcemap)));
|
|
440
|
-
const failures = testCases.filter((test)=>'fail' === test.status).length;
|
|
441
|
-
const errors = 0;
|
|
442
|
-
const skipped = testCases.filter((test)=>'skip' === test.status || 'todo' === test.status).length;
|
|
443
|
-
const totalTime = testCases.reduce((sum, test)=>sum + test.time, 0);
|
|
444
|
-
return {
|
|
445
|
-
name: (0, pathe_M_eThtNZ.b)(this.rootPath, fileResult.testPath),
|
|
446
|
-
tests: testCases.length,
|
|
447
|
-
failures,
|
|
448
|
-
errors,
|
|
449
|
-
skipped,
|
|
450
|
-
time: totalTime,
|
|
451
|
-
timestamp: new Date().toISOString(),
|
|
452
|
-
testcases: testCases
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
generateJUnitXml(report) {
|
|
456
|
-
const xmlDeclaration = '<?xml version="1.0" encoding="UTF-8"?>';
|
|
457
|
-
const testsuitesXml = `
|
|
458
|
-
<testsuites name="${this.escapeXml(report.testsuites.name)}" tests="${report.testsuites.tests}" failures="${report.testsuites.failures}" errors="${report.testsuites.errors}" skipped="${report.testsuites.skipped}" time="${report.testsuites.time}" timestamp="${this.escapeXml(report.testsuites.timestamp)}">`;
|
|
459
|
-
const testsuiteXmls = report.testsuites.testsuite.map((suite)=>{
|
|
460
|
-
const testsuiteStart = `
|
|
461
|
-
<testsuite name="${this.escapeXml(suite.name)}" tests="${suite.tests}" failures="${suite.failures}" errors="${suite.errors}" skipped="${suite.skipped}" time="${suite.time}" timestamp="${this.escapeXml(suite.timestamp)}">`;
|
|
462
|
-
const testcaseXmls = suite.testcases.map((testcase)=>{
|
|
463
|
-
let testcaseXml = `
|
|
464
|
-
<testcase name="${this.escapeXml(testcase.name)}" classname="${this.escapeXml(testcase.classname)}" time="${testcase.time}">`;
|
|
465
|
-
if ('skip' === testcase.status || 'todo' === testcase.status) testcaseXml += `
|
|
466
|
-
<skipped/>`;
|
|
467
|
-
else if ('fail' === testcase.status && testcase.errors) testcase.errors.forEach((error)=>{
|
|
468
|
-
testcaseXml += `
|
|
469
|
-
<failure message="${error.message}" type="${error.type}">${error.details || ''}</failure>`;
|
|
470
|
-
});
|
|
471
|
-
testcaseXml += `
|
|
472
|
-
</testcase>`;
|
|
473
|
-
return testcaseXml;
|
|
474
|
-
}).join('');
|
|
475
|
-
const testsuiteEnd = `
|
|
476
|
-
</testsuite>`;
|
|
477
|
-
return testsuiteStart + testcaseXmls + testsuiteEnd;
|
|
478
|
-
}).join('');
|
|
479
|
-
const testsuitesEnd = `
|
|
480
|
-
</testsuites>`;
|
|
481
|
-
return xmlDeclaration + testsuitesXml + testsuiteXmls + testsuitesEnd;
|
|
482
|
-
}
|
|
483
|
-
async onTestRunEnd({ results, testResults, duration, getSourcemap }) {
|
|
484
|
-
const testSuites = await Promise.all(results.map(async (fileResult)=>this.createJUnitTestSuite(fileResult, getSourcemap)));
|
|
485
|
-
const totalTests = testResults.length;
|
|
486
|
-
const totalFailures = testResults.filter((test)=>'fail' === test.status).length;
|
|
487
|
-
const totalErrors = 0;
|
|
488
|
-
const totalSkipped = testResults.filter((test)=>'skip' === test.status || 'todo' === test.status).length;
|
|
489
|
-
const totalTime = duration.testTime / 1000;
|
|
490
|
-
const report = {
|
|
491
|
-
testsuites: {
|
|
492
|
-
name: 'rstest tests',
|
|
493
|
-
tests: totalTests,
|
|
494
|
-
failures: totalFailures,
|
|
495
|
-
errors: totalErrors,
|
|
496
|
-
skipped: totalSkipped,
|
|
497
|
-
time: totalTime,
|
|
498
|
-
timestamp: new Date().toISOString(),
|
|
499
|
-
testsuite: testSuites
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
const xmlContent = this.generateJUnitXml(report);
|
|
503
|
-
if (this.outputPath) try {
|
|
504
|
-
await (0, promises_.writeFile)(this.outputPath, xmlContent, 'utf-8');
|
|
505
|
-
console.log(`JUnit XML report written to: ${this.outputPath}`);
|
|
506
|
-
} catch (error) {
|
|
507
|
-
console.error(`Failed to write JUnit XML report to ${this.outputPath}:`, error);
|
|
508
|
-
console.log('JUnit XML Report:');
|
|
509
|
-
console.log(xmlContent);
|
|
510
|
-
}
|
|
511
|
-
else console.log(xmlContent);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
class VerboseReporter extends DefaultReporter {
|
|
515
|
-
onTestFileResult(test) {
|
|
516
|
-
this.statusRenderer?.removeRunningModule(test.testPath);
|
|
517
|
-
const relativePath = (0, pathe_M_eThtNZ.b)(this.rootPath, test.testPath);
|
|
518
|
-
const { slowTestThreshold } = this.config;
|
|
519
|
-
logFileTitle(test, relativePath, slowTestThreshold, true);
|
|
520
|
-
for (const result of test.results)logCase(result, slowTestThreshold);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
function formatEnvironmentName(name) {
|
|
524
|
-
return name.replace(/[^a-zA-Z0-9\-_$]/g, '_');
|
|
525
|
-
}
|
|
526
|
-
class Rstest {
|
|
527
|
-
cwd;
|
|
528
|
-
command;
|
|
529
|
-
fileFilters;
|
|
530
|
-
configFilePath;
|
|
531
|
-
reporters;
|
|
532
|
-
snapshotManager;
|
|
533
|
-
version;
|
|
534
|
-
rootPath;
|
|
535
|
-
originalConfig;
|
|
536
|
-
normalizedConfig;
|
|
537
|
-
idMap = new Map();
|
|
538
|
-
reporterResults = {
|
|
539
|
-
results: [],
|
|
540
|
-
testResults: []
|
|
541
|
-
};
|
|
542
|
-
projects = [];
|
|
543
|
-
constructor({ cwd = process.cwd(), command, fileFilters, configFilePath, projects }, userConfig){
|
|
544
|
-
this.cwd = cwd;
|
|
545
|
-
this.command = command;
|
|
546
|
-
this.fileFilters = fileFilters;
|
|
547
|
-
this.configFilePath = configFilePath;
|
|
548
|
-
const rootPath = userConfig.root ? (0, utils.FI)(cwd, userConfig.root) : cwd;
|
|
549
|
-
const rstestConfig = (0, src_config.wX)({
|
|
550
|
-
...userConfig,
|
|
551
|
-
root: rootPath
|
|
552
|
-
});
|
|
553
|
-
const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
|
|
554
|
-
rootPath,
|
|
555
|
-
config: rstestConfig
|
|
556
|
-
}) : [];
|
|
557
|
-
const snapshotManager = new manager.CW({
|
|
558
|
-
updateSnapshot: rstestConfig.update ? 'all' : dist.JO ? 'none' : 'new'
|
|
559
|
-
});
|
|
560
|
-
this.reporters = reporters;
|
|
561
|
-
this.snapshotManager = snapshotManager;
|
|
562
|
-
this.version = "0.5.1";
|
|
563
|
-
this.rootPath = rootPath;
|
|
564
|
-
this.originalConfig = userConfig;
|
|
565
|
-
this.normalizedConfig = rstestConfig;
|
|
566
|
-
this.projects = projects.length ? projects.map((project)=>{
|
|
567
|
-
const config = (0, src_config.wX)(project.config);
|
|
568
|
-
config.isolate = rstestConfig.isolate;
|
|
569
|
-
config.source ??= {};
|
|
570
|
-
config.coverage = rstestConfig.coverage;
|
|
571
|
-
if (!config.source.tsconfigPath) {
|
|
572
|
-
const tsconfigPath = (0, pathe_M_eThtNZ.j)(config.root, utils.WB);
|
|
573
|
-
if ((0, external_node_fs_.existsSync)(tsconfigPath)) config.source.tsconfigPath = tsconfigPath;
|
|
574
|
-
}
|
|
575
|
-
return {
|
|
576
|
-
configFilePath: project.configFilePath,
|
|
577
|
-
rootPath: config.root,
|
|
578
|
-
name: config.name,
|
|
579
|
-
environmentName: formatEnvironmentName(config.name),
|
|
580
|
-
normalizedConfig: config
|
|
581
|
-
};
|
|
582
|
-
}) : [
|
|
583
|
-
{
|
|
584
|
-
configFilePath,
|
|
585
|
-
rootPath,
|
|
586
|
-
name: rstestConfig.name,
|
|
587
|
-
environmentName: formatEnvironmentName(rstestConfig.name),
|
|
588
|
-
normalizedConfig: rstestConfig
|
|
589
|
-
}
|
|
590
|
-
];
|
|
591
|
-
}
|
|
592
|
-
updateReporterResultState(results, testResults, deletedEntries = []) {
|
|
593
|
-
results.forEach((item)=>{
|
|
594
|
-
const existingIndex = this.reporterResults.results.findIndex((r)=>r.testPath === item.testPath);
|
|
595
|
-
if (-1 !== existingIndex) this.reporterResults.results[existingIndex] = item;
|
|
596
|
-
else this.reporterResults.results.push(item);
|
|
597
|
-
});
|
|
598
|
-
const testPathsToUpdate = new Set(testResults.map((r)=>r.testPath));
|
|
599
|
-
this.reporterResults.testResults = this.reporterResults.testResults.filter((r)=>!testPathsToUpdate.has(r.testPath));
|
|
600
|
-
this.reporterResults.testResults.push(...testResults);
|
|
601
|
-
if (deletedEntries.length > 0) {
|
|
602
|
-
const deletedPathsSet = new Set(deletedEntries);
|
|
603
|
-
this.reporterResults.results = this.reporterResults.results.filter((r)=>!deletedPathsSet.has(r.testPath));
|
|
604
|
-
this.reporterResults.testResults = this.reporterResults.testResults.filter((r)=>!deletedPathsSet.has(r.testPath));
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
const reportersMap = {
|
|
609
|
-
default: DefaultReporter,
|
|
610
|
-
verbose: VerboseReporter,
|
|
611
|
-
'github-actions': GithubActionsReporter,
|
|
612
|
-
junit: JUnitReporter
|
|
613
|
-
};
|
|
614
|
-
function createReporters(reporters, initOptions = {}) {
|
|
615
|
-
const result = (0, utils.bg)(reporters).map((reporter)=>{
|
|
616
|
-
if ('string' == typeof reporter || Array.isArray(reporter)) {
|
|
617
|
-
const [name, options = {}] = 'string' == typeof reporter ? [
|
|
618
|
-
reporter,
|
|
619
|
-
{}
|
|
620
|
-
] : reporter;
|
|
621
|
-
if (name in reportersMap) {
|
|
622
|
-
const Reporter = reportersMap[name];
|
|
623
|
-
return new Reporter({
|
|
624
|
-
...initOptions,
|
|
625
|
-
options
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
throw new Error(`Reporter ${reporter} not found. Please install it or use a built-in reporter.`);
|
|
629
|
-
}
|
|
630
|
-
return reporter;
|
|
631
|
-
});
|
|
632
|
-
return result;
|
|
633
|
-
}
|
|
634
|
-
function createRstest({ config, projects, configFilePath }, command, fileFilters) {
|
|
635
|
-
const context = new Rstest({
|
|
636
|
-
cwd: process.cwd(),
|
|
637
|
-
command,
|
|
638
|
-
fileFilters,
|
|
639
|
-
configFilePath,
|
|
640
|
-
projects
|
|
641
|
-
}, config);
|
|
642
|
-
const runTests = async ()=>{
|
|
643
|
-
const { runTests } = await Promise.all([
|
|
644
|
-
__webpack_require__.e("816"),
|
|
645
|
-
__webpack_require__.e("33")
|
|
646
|
-
]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
|
|
647
|
-
await runTests(context);
|
|
648
|
-
};
|
|
649
|
-
const listTests = async (options)=>{
|
|
650
|
-
const { listTests } = await Promise.all([
|
|
651
|
-
__webpack_require__.e("816"),
|
|
652
|
-
__webpack_require__.e("971")
|
|
653
|
-
]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
|
|
654
|
-
await listTests(context, options);
|
|
655
|
-
};
|
|
656
|
-
return {
|
|
657
|
-
context,
|
|
658
|
-
runTests,
|
|
659
|
-
listTests
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
},
|
|
663
|
-
"./src/utils/error.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
664
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
665
|
-
C: ()=>formatStack,
|
|
666
|
-
parseErrorStacktrace: ()=>parseErrorStacktrace,
|
|
667
|
-
printError: ()=>printError
|
|
668
|
-
});
|
|
669
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
670
|
-
var _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs");
|
|
671
|
-
var stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
|
|
672
|
-
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
673
|
-
async function printError(error, getSourcemap, rootPath) {
|
|
674
|
-
const errorName = error.name || 'Unknown Error';
|
|
675
|
-
if (error.message.includes('Vitest failed to access its internal state')) {
|
|
676
|
-
const tips = [
|
|
677
|
-
'Error: not support import `vitest` in Rstest test environment.\n',
|
|
678
|
-
'Solution:',
|
|
679
|
-
` - Update your code to use imports from "${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.yellow('@rstest/core')}" instead of "${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.yellow('vitest')}".`,
|
|
680
|
-
' - Enable `globals` configuration and use global API.'
|
|
681
|
-
];
|
|
682
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(`${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.red(tips.join('\n'))}\n`);
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
if (error.message.includes('is not defined')) {
|
|
686
|
-
const [, varName] = error.message.match(/(.*) is not defined/) || [];
|
|
687
|
-
if (varName) {
|
|
688
|
-
if (_utils__WEBPACK_IMPORTED_MODULE_3__.TE.includes(varName)) error.message = error.message.replace(`${varName} is not defined`, `${varName} is not defined. Did you forget to enable "globals" configuration?`);
|
|
689
|
-
else if ([
|
|
690
|
-
'jest',
|
|
691
|
-
'vitest'
|
|
692
|
-
].includes(varName)) error.message = error.message.replace(`${varName} is not defined`, `${varName} is not defined. Did you mean rstest?`);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(`${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.red(_utils__WEBPACK_IMPORTED_MODULE_3__.yW.bold(errorName))}${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.red(`: ${error.message}`)}\n`);
|
|
696
|
-
if (error.diff) {
|
|
697
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(error.diff);
|
|
698
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.vF.log();
|
|
699
|
-
}
|
|
700
|
-
if (error.stack) {
|
|
701
|
-
const stackFrames = await parseErrorStacktrace({
|
|
702
|
-
stack: error.stack,
|
|
703
|
-
fullStack: error.fullStack,
|
|
704
|
-
getSourcemap
|
|
705
|
-
});
|
|
706
|
-
if (!stackFrames.length && error.stack.length) _utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(_utils__WEBPACK_IMPORTED_MODULE_3__.yW.gray("No error stack found, set 'DEBUG=rstest' to show fullStack."));
|
|
707
|
-
if (stackFrames[0]) await printCodeFrame(stackFrames[0]);
|
|
708
|
-
printStack(stackFrames, rootPath);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
async function printCodeFrame(frame) {
|
|
712
|
-
const filePath = frame.file?.startsWith('file') ? new URL(frame.file) : frame.file;
|
|
713
|
-
if (!filePath) return;
|
|
714
|
-
const source = node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(filePath) ? node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].readFileSync(filePath, 'utf-8') : void 0;
|
|
715
|
-
if (!source) return;
|
|
716
|
-
const { codeFrameColumns } = await __webpack_require__.e("171").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/@babel+code-frame@7.27.1/node_modules/@babel/code-frame/lib/index.js"));
|
|
717
|
-
const result = codeFrameColumns(source, {
|
|
718
|
-
start: {
|
|
719
|
-
line: frame.lineNumber,
|
|
720
|
-
column: frame.column
|
|
721
|
-
}
|
|
722
|
-
}, {
|
|
723
|
-
highlightCode: true,
|
|
724
|
-
linesBelow: 2
|
|
725
|
-
});
|
|
726
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(result);
|
|
727
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.vF.log('');
|
|
728
|
-
}
|
|
729
|
-
function formatStack(frame, rootPath) {
|
|
730
|
-
return '<unknown>' !== frame.methodName ? `at ${frame.methodName} (${(0, _utils__WEBPACK_IMPORTED_MODULE_3__.XJ)(rootPath, frame.file)}:${frame.lineNumber}:${frame.column})` : `at ${(0, _utils__WEBPACK_IMPORTED_MODULE_3__.XJ)(rootPath, frame.file)}:${frame.lineNumber}:${frame.column}`;
|
|
731
|
-
}
|
|
732
|
-
function printStack(stackFrames, rootPath) {
|
|
733
|
-
for (const frame of stackFrames)_utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(_utils__WEBPACK_IMPORTED_MODULE_3__.yW.gray(` ${formatStack(frame, rootPath)}`));
|
|
734
|
-
stackFrames.length && _utils__WEBPACK_IMPORTED_MODULE_3__.vF.log();
|
|
735
|
-
}
|
|
736
|
-
const stackIgnores = [
|
|
737
|
-
/\/@rstest\/core/,
|
|
738
|
-
/rstest\/packages\/core\/dist/,
|
|
739
|
-
/node_modules\/tinypool/,
|
|
740
|
-
/node_modules\/chai/,
|
|
741
|
-
/node_modules\/@vitest\/expect/,
|
|
742
|
-
/node_modules\/@vitest\/snapshot/,
|
|
743
|
-
/node:\w+/,
|
|
744
|
-
/webpack\/runtime/,
|
|
745
|
-
/webpack\\runtime/,
|
|
746
|
-
'<anonymous>'
|
|
747
|
-
];
|
|
748
|
-
async function parseErrorStacktrace({ stack, getSourcemap, fullStack = (0, _utils__WEBPACK_IMPORTED_MODULE_3__._o)() }) {
|
|
749
|
-
const stackFrames = await Promise.all((0, stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__.q)(stack).filter((frame)=>fullStack ? true : frame.file && !stackIgnores.some((entry)=>frame.file?.match(entry))).map(async (frame)=>{
|
|
750
|
-
const sourcemap = getSourcemap(frame.file);
|
|
751
|
-
if (sourcemap) {
|
|
752
|
-
const traceMap = new _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__.YX(sourcemap);
|
|
753
|
-
const { line, column, source, name } = (0, _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__.sP)(traceMap, {
|
|
754
|
-
line: frame.lineNumber,
|
|
755
|
-
column: frame.column
|
|
756
|
-
});
|
|
757
|
-
if (!source) return null;
|
|
758
|
-
return {
|
|
759
|
-
...frame,
|
|
760
|
-
file: source,
|
|
761
|
-
lineNumber: line,
|
|
762
|
-
name,
|
|
763
|
-
column
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
return frame;
|
|
767
|
-
})).then((frames)=>frames.filter((frame)=>null !== frame));
|
|
768
|
-
return stackFrames;
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
};
|