@rstest/core 0.6.5 → 0.6.6
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/{0~814.js → 0~122.js} +12 -7
- package/dist/{0~607.js → 0~130.js} +1 -1
- package/dist/{0~764.js → 0~151.js} +44 -6
- package/dist/{0~470.js → 0~173.js} +5 -5
- package/dist/{0~836.js → 0~255.js} +2 -2
- package/dist/{0~204.js → 0~403.js} +2 -2
- package/dist/{0~691.js → 0~426.js} +1 -1
- package/dist/{0~830.js → 0~454.js} +1 -1
- package/dist/{0~263.js → 0~583.js} +4 -4
- package/dist/{0~365.js → 0~588.js} +4 -4
- package/dist/{0~711.js → 0~62.js} +2 -2
- package/dist/{0~971.js → 0~634.js} +4 -4
- package/dist/{0~350.js → 0~809.js} +2 -2
- package/dist/{0~171.js → 0~919.js} +1 -1
- package/dist/155.js +2561 -0
- package/dist/362.js +7262 -0
- package/dist/{603.js → 734.js} +2 -2
- package/dist/{857.js → 946.js} +2 -2
- package/dist/index.js +1 -2516
- package/dist/worker.js +3 -7240
- package/dist-types/index.d.ts +22 -0
- package/dist-types/worker.d.ts +20 -5
- package/package.json +1 -1
- /package/dist/{0~764.js.LICENSE.txt → 0~151.js.LICENSE.txt} +0 -0
- /package/dist/{0~263.js.LICENSE.txt → 0~583.js.LICENSE.txt} +0 -0
- /package/dist/{0~463.js → 0~681.js} +0 -0
- /package/dist/{worker.js.LICENSE.txt → 362.js.LICENSE.txt} +0 -0
- /package/dist/{597.js → 397.js} +0 -0
- /package/dist/{808.js → 770.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,2518 +1,3 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
|
|
4
|
-
import { EventEmitter } from "events";
|
|
5
|
-
import { createRsbuild, loadConfig, logger, mergeRsbuildConfig } from "@rsbuild/core";
|
|
6
|
-
import { basename, DEFAULT_CONFIG_EXTENSIONS, TS_CONFIG_FILE, isTTY, dirname, posix, resolve as pathe_M_eThtNZ_resolve, pathe_M_eThtNZ_relative, DEFAULT_CONFIG_NAME, globalApis, formatTestPath, getAbsolutePath, filterProjects, join, formatRootStr, isDynamicPattern, glob, writeFile, castArray, src_logger, prettyTestPath, prettyTime, isDebug, isAbsolute, getTaskNameWithPrefix, formatError, normalize, TEMP_RSTEST_OUTPUT_DIR_GLOB } from "./857.js";
|
|
7
|
-
import { decode } from "./597.js";
|
|
8
|
-
function toArr(any) {
|
|
9
|
-
return null == any ? [] : Array.isArray(any) ? any : [
|
|
10
|
-
any
|
|
11
|
-
];
|
|
12
|
-
}
|
|
13
|
-
function toVal(out, key, val, opts) {
|
|
14
|
-
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || true === val ? '' : String(val) : 'boolean' == typeof val ? val : ~opts.boolean.indexOf(key) ? 'false' === val ? false : 'true' === val || (out._.push((x = +val, 0 * x === 0) ? x : val), !!val) : (x = +val, 0 * x === 0) ? x : val;
|
|
15
|
-
out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
|
|
16
|
-
old,
|
|
17
|
-
nxt
|
|
18
|
-
];
|
|
19
|
-
}
|
|
20
|
-
function mri2(args, opts) {
|
|
21
|
-
args = args || [];
|
|
22
|
-
opts = opts || {};
|
|
23
|
-
var k, arr, arg, name, val, out = {
|
|
24
|
-
_: []
|
|
25
|
-
};
|
|
26
|
-
var i = 0, j = 0, idx = 0, len = args.length;
|
|
27
|
-
const alibi = void 0 !== opts.alias;
|
|
28
|
-
const strict = void 0 !== opts.unknown;
|
|
29
|
-
const defaults = void 0 !== opts.default;
|
|
30
|
-
opts.alias = opts.alias || {};
|
|
31
|
-
opts.string = toArr(opts.string);
|
|
32
|
-
opts.boolean = toArr(opts.boolean);
|
|
33
|
-
if (alibi) for(k in opts.alias){
|
|
34
|
-
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
35
|
-
for(i = 0; i < arr.length; i++)(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
36
|
-
}
|
|
37
|
-
for(i = opts.boolean.length; i-- > 0;){
|
|
38
|
-
arr = opts.alias[opts.boolean[i]] || [];
|
|
39
|
-
for(j = arr.length; j-- > 0;)opts.boolean.push(arr[j]);
|
|
40
|
-
}
|
|
41
|
-
for(i = opts.string.length; i-- > 0;){
|
|
42
|
-
arr = opts.alias[opts.string[i]] || [];
|
|
43
|
-
for(j = arr.length; j-- > 0;)opts.string.push(arr[j]);
|
|
44
|
-
}
|
|
45
|
-
if (defaults) for(k in opts.default){
|
|
46
|
-
name = typeof opts.default[k];
|
|
47
|
-
arr = opts.alias[k] = opts.alias[k] || [];
|
|
48
|
-
if (void 0 !== opts[name]) {
|
|
49
|
-
opts[name].push(k);
|
|
50
|
-
for(i = 0; i < arr.length; i++)opts[name].push(arr[i]);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const keys = strict ? Object.keys(opts.alias) : [];
|
|
54
|
-
for(i = 0; i < len; i++){
|
|
55
|
-
arg = args[i];
|
|
56
|
-
if ('--' === arg) {
|
|
57
|
-
out._ = out._.concat(args.slice(++i));
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
|
|
61
|
-
if (0 === j) out._.push(arg);
|
|
62
|
-
else if ('no-' === arg.substring(j, j + 3)) {
|
|
63
|
-
name = arg.substring(j + 3);
|
|
64
|
-
if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
65
|
-
out[name] = false;
|
|
66
|
-
} else {
|
|
67
|
-
for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
|
|
68
|
-
name = arg.substring(j, idx);
|
|
69
|
-
val = arg.substring(++idx) || i + 1 === len || 45 === ('' + args[i + 1]).charCodeAt(0) || args[++i];
|
|
70
|
-
arr = 2 === j ? [
|
|
71
|
-
name
|
|
72
|
-
] : name;
|
|
73
|
-
for(idx = 0; idx < arr.length; idx++){
|
|
74
|
-
name = arr[idx];
|
|
75
|
-
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
|
76
|
-
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (defaults) {
|
|
81
|
-
for(k in opts.default)if (void 0 === out[k]) out[k] = opts.default[k];
|
|
82
|
-
}
|
|
83
|
-
if (alibi) for(k in out){
|
|
84
|
-
arr = opts.alias[k] || [];
|
|
85
|
-
while(arr.length > 0)out[arr.shift()] = out[k];
|
|
86
|
-
}
|
|
87
|
-
return out;
|
|
88
|
-
}
|
|
89
|
-
const removeBrackets = (v)=>v.replace(/[<[].+/, "").trim();
|
|
90
|
-
const findAllBrackets = (v)=>{
|
|
91
|
-
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
92
|
-
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
93
|
-
const res = [];
|
|
94
|
-
const parse = (match)=>{
|
|
95
|
-
let variadic = false;
|
|
96
|
-
let value = match[1];
|
|
97
|
-
if (value.startsWith("...")) {
|
|
98
|
-
value = value.slice(3);
|
|
99
|
-
variadic = true;
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
required: match[0].startsWith("<"),
|
|
103
|
-
value,
|
|
104
|
-
variadic
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
let angledMatch;
|
|
108
|
-
while(angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v))res.push(parse(angledMatch));
|
|
109
|
-
let squareMatch;
|
|
110
|
-
while(squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v))res.push(parse(squareMatch));
|
|
111
|
-
return res;
|
|
112
|
-
};
|
|
113
|
-
const getMriOptions = (options)=>{
|
|
114
|
-
const result = {
|
|
115
|
-
alias: {},
|
|
116
|
-
boolean: []
|
|
117
|
-
};
|
|
118
|
-
for (const [index, option] of options.entries()){
|
|
119
|
-
if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
|
|
120
|
-
if (option.isBoolean) if (option.negated) {
|
|
121
|
-
const hasStringTypeOption = options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required);
|
|
122
|
-
if (!hasStringTypeOption) result.boolean.push(option.names[0]);
|
|
123
|
-
} else result.boolean.push(option.names[0]);
|
|
124
|
-
}
|
|
125
|
-
return result;
|
|
126
|
-
};
|
|
127
|
-
const findLongest = (arr)=>arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
|
|
128
|
-
const padRight = (str, length)=>str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
129
|
-
const camelcase = (input)=>input.replace(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
|
|
130
|
-
const setDotProp = (obj, keys, val)=>{
|
|
131
|
-
let i = 0;
|
|
132
|
-
let length = keys.length;
|
|
133
|
-
let t = obj;
|
|
134
|
-
let x;
|
|
135
|
-
for(; i < length; ++i){
|
|
136
|
-
x = t[keys[i]];
|
|
137
|
-
t = t[keys[i]] = i === length - 1 ? val : null != x ? x : !~keys[i + 1].indexOf(".") && +keys[i + 1] > -1 ? [] : {};
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
const setByType = (obj, transforms)=>{
|
|
141
|
-
for (const key of Object.keys(transforms)){
|
|
142
|
-
const transform = transforms[key];
|
|
143
|
-
if (transform.shouldTransform) {
|
|
144
|
-
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
145
|
-
if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
const getFileName = (input)=>{
|
|
150
|
-
const m = /([^\\\/]+)$/.exec(input);
|
|
151
|
-
return m ? m[1] : "";
|
|
152
|
-
};
|
|
153
|
-
const camelcaseOptionName = (name)=>name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
|
|
154
|
-
class CACError extends Error {
|
|
155
|
-
constructor(message){
|
|
156
|
-
super(message);
|
|
157
|
-
this.name = this.constructor.name;
|
|
158
|
-
if ("function" == typeof Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
159
|
-
else this.stack = new Error(message).stack;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
class Option {
|
|
163
|
-
constructor(rawName, description, config){
|
|
164
|
-
this.rawName = rawName;
|
|
165
|
-
this.description = description;
|
|
166
|
-
this.config = Object.assign({}, config);
|
|
167
|
-
rawName = rawName.replace(/\.\*/g, "");
|
|
168
|
-
this.negated = false;
|
|
169
|
-
this.names = removeBrackets(rawName).split(",").map((v)=>{
|
|
170
|
-
let name = v.trim().replace(/^-{1,2}/, "");
|
|
171
|
-
if (name.startsWith("no-")) {
|
|
172
|
-
this.negated = true;
|
|
173
|
-
name = name.replace(/^no-/, "");
|
|
174
|
-
}
|
|
175
|
-
return camelcaseOptionName(name);
|
|
176
|
-
}).sort((a, b)=>a.length > b.length ? 1 : -1);
|
|
177
|
-
this.name = this.names[this.names.length - 1];
|
|
178
|
-
if (this.negated && null == this.config.default) this.config.default = true;
|
|
179
|
-
if (rawName.includes("<")) this.required = true;
|
|
180
|
-
else if (rawName.includes("[")) this.required = false;
|
|
181
|
-
else this.isBoolean = true;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const processArgs = process.argv;
|
|
185
|
-
const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
186
|
-
class Command {
|
|
187
|
-
constructor(rawName, description, config = {}, cli){
|
|
188
|
-
this.rawName = rawName;
|
|
189
|
-
this.description = description;
|
|
190
|
-
this.config = config;
|
|
191
|
-
this.cli = cli;
|
|
192
|
-
this.options = [];
|
|
193
|
-
this.aliasNames = [];
|
|
194
|
-
this.name = removeBrackets(rawName);
|
|
195
|
-
this.args = findAllBrackets(rawName);
|
|
196
|
-
this.examples = [];
|
|
197
|
-
}
|
|
198
|
-
usage(text) {
|
|
199
|
-
this.usageText = text;
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
allowUnknownOptions() {
|
|
203
|
-
this.config.allowUnknownOptions = true;
|
|
204
|
-
return this;
|
|
205
|
-
}
|
|
206
|
-
ignoreOptionDefaultValue() {
|
|
207
|
-
this.config.ignoreOptionDefaultValue = true;
|
|
208
|
-
return this;
|
|
209
|
-
}
|
|
210
|
-
version(version, customFlags = "-v, --version") {
|
|
211
|
-
this.versionNumber = version;
|
|
212
|
-
this.option(customFlags, "Display version number");
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
example(example) {
|
|
216
|
-
this.examples.push(example);
|
|
217
|
-
return this;
|
|
218
|
-
}
|
|
219
|
-
option(rawName, description, config) {
|
|
220
|
-
const option = new Option(rawName, description, config);
|
|
221
|
-
this.options.push(option);
|
|
222
|
-
return this;
|
|
223
|
-
}
|
|
224
|
-
alias(name) {
|
|
225
|
-
this.aliasNames.push(name);
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
action(callback) {
|
|
229
|
-
this.commandAction = callback;
|
|
230
|
-
return this;
|
|
231
|
-
}
|
|
232
|
-
isMatched(name) {
|
|
233
|
-
return this.name === name || this.aliasNames.includes(name);
|
|
234
|
-
}
|
|
235
|
-
get isDefaultCommand() {
|
|
236
|
-
return "" === this.name || this.aliasNames.includes("!");
|
|
237
|
-
}
|
|
238
|
-
get isGlobalCommand() {
|
|
239
|
-
return this instanceof GlobalCommand;
|
|
240
|
-
}
|
|
241
|
-
hasOption(name) {
|
|
242
|
-
name = name.split(".")[0];
|
|
243
|
-
return this.options.find((option)=>option.names.includes(name));
|
|
244
|
-
}
|
|
245
|
-
outputHelp() {
|
|
246
|
-
const { name, commands } = this.cli;
|
|
247
|
-
const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
|
|
248
|
-
let sections = [
|
|
249
|
-
{
|
|
250
|
-
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
251
|
-
}
|
|
252
|
-
];
|
|
253
|
-
sections.push({
|
|
254
|
-
title: "Usage",
|
|
255
|
-
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
256
|
-
});
|
|
257
|
-
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
258
|
-
if (showCommands) {
|
|
259
|
-
const longestCommandName = findLongest(commands.map((command)=>command.rawName));
|
|
260
|
-
sections.push({
|
|
261
|
-
title: "Commands",
|
|
262
|
-
body: commands.map((command)=>` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`).join("\n")
|
|
263
|
-
});
|
|
264
|
-
sections.push({
|
|
265
|
-
title: "For more info, run any command with the `--help` flag",
|
|
266
|
-
body: commands.map((command)=>` $ ${name}${"" === command.name ? "" : ` ${command.name}`} --help`).join("\n")
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
let options = this.isGlobalCommand ? globalOptions : [
|
|
270
|
-
...this.options,
|
|
271
|
-
...globalOptions || []
|
|
272
|
-
];
|
|
273
|
-
if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option)=>"version" !== option.name);
|
|
274
|
-
if (options.length > 0) {
|
|
275
|
-
const longestOptionName = findLongest(options.map((option)=>option.rawName));
|
|
276
|
-
sections.push({
|
|
277
|
-
title: "Options",
|
|
278
|
-
body: options.map((option)=>` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${void 0 === option.config.default ? "" : `(default: ${option.config.default})`}`).join("\n")
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
if (this.examples.length > 0) sections.push({
|
|
282
|
-
title: "Examples",
|
|
283
|
-
body: this.examples.map((example)=>{
|
|
284
|
-
if ("function" == typeof example) return example(name);
|
|
285
|
-
return example;
|
|
286
|
-
}).join("\n")
|
|
287
|
-
});
|
|
288
|
-
if (helpCallback) sections = helpCallback(sections) || sections;
|
|
289
|
-
console.log(sections.map((section)=>section.title ? `${section.title}:
|
|
290
|
-
${section.body}` : section.body).join("\n\n"));
|
|
291
|
-
}
|
|
292
|
-
outputVersion() {
|
|
293
|
-
const { name } = this.cli;
|
|
294
|
-
const { versionNumber } = this.cli.globalCommand;
|
|
295
|
-
if (versionNumber) console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
296
|
-
}
|
|
297
|
-
checkRequiredArgs() {
|
|
298
|
-
const minimalArgsCount = this.args.filter((arg)=>arg.required).length;
|
|
299
|
-
if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
300
|
-
}
|
|
301
|
-
checkUnknownOptions() {
|
|
302
|
-
const { options, globalCommand } = this.cli;
|
|
303
|
-
if (!this.config.allowUnknownOptions) {
|
|
304
|
-
for (const name of Object.keys(options))if ("--" !== name && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
checkOptionValue() {
|
|
308
|
-
const { options: parsedOptions, globalCommand } = this.cli;
|
|
309
|
-
const options = [
|
|
310
|
-
...globalCommand.options,
|
|
311
|
-
...this.options
|
|
312
|
-
];
|
|
313
|
-
for (const option of options){
|
|
314
|
-
const value = parsedOptions[option.name.split(".")[0]];
|
|
315
|
-
if (option.required) {
|
|
316
|
-
const hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
|
|
317
|
-
if (true === value || false === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
class GlobalCommand extends Command {
|
|
323
|
-
constructor(cli){
|
|
324
|
-
super("@@global@@", "", {}, cli);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
var __assign = Object.assign;
|
|
328
|
-
class CAC extends EventEmitter {
|
|
329
|
-
constructor(name = ""){
|
|
330
|
-
super();
|
|
331
|
-
this.name = name;
|
|
332
|
-
this.commands = [];
|
|
333
|
-
this.rawArgs = [];
|
|
334
|
-
this.args = [];
|
|
335
|
-
this.options = {};
|
|
336
|
-
this.globalCommand = new GlobalCommand(this);
|
|
337
|
-
this.globalCommand.usage("<command> [options]");
|
|
338
|
-
}
|
|
339
|
-
usage(text) {
|
|
340
|
-
this.globalCommand.usage(text);
|
|
341
|
-
return this;
|
|
342
|
-
}
|
|
343
|
-
command(rawName, description, config) {
|
|
344
|
-
const command = new Command(rawName, description || "", config, this);
|
|
345
|
-
command.globalCommand = this.globalCommand;
|
|
346
|
-
this.commands.push(command);
|
|
347
|
-
return command;
|
|
348
|
-
}
|
|
349
|
-
option(rawName, description, config) {
|
|
350
|
-
this.globalCommand.option(rawName, description, config);
|
|
351
|
-
return this;
|
|
352
|
-
}
|
|
353
|
-
help(callback) {
|
|
354
|
-
this.globalCommand.option("-h, --help", "Display this message");
|
|
355
|
-
this.globalCommand.helpCallback = callback;
|
|
356
|
-
this.showHelpOnExit = true;
|
|
357
|
-
return this;
|
|
358
|
-
}
|
|
359
|
-
version(version, customFlags = "-v, --version") {
|
|
360
|
-
this.globalCommand.version(version, customFlags);
|
|
361
|
-
this.showVersionOnExit = true;
|
|
362
|
-
return this;
|
|
363
|
-
}
|
|
364
|
-
example(example) {
|
|
365
|
-
this.globalCommand.example(example);
|
|
366
|
-
return this;
|
|
367
|
-
}
|
|
368
|
-
outputHelp() {
|
|
369
|
-
if (this.matchedCommand) this.matchedCommand.outputHelp();
|
|
370
|
-
else this.globalCommand.outputHelp();
|
|
371
|
-
}
|
|
372
|
-
outputVersion() {
|
|
373
|
-
this.globalCommand.outputVersion();
|
|
374
|
-
}
|
|
375
|
-
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
376
|
-
this.args = args;
|
|
377
|
-
this.options = options;
|
|
378
|
-
if (matchedCommand) this.matchedCommand = matchedCommand;
|
|
379
|
-
if (matchedCommandName) this.matchedCommandName = matchedCommandName;
|
|
380
|
-
return this;
|
|
381
|
-
}
|
|
382
|
-
unsetMatchedCommand() {
|
|
383
|
-
this.matchedCommand = void 0;
|
|
384
|
-
this.matchedCommandName = void 0;
|
|
385
|
-
}
|
|
386
|
-
parse(argv = processArgs, { run = true } = {}) {
|
|
387
|
-
this.rawArgs = argv;
|
|
388
|
-
if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
389
|
-
let shouldParse = true;
|
|
390
|
-
for (const command of this.commands){
|
|
391
|
-
const parsed = this.mri(argv.slice(2), command);
|
|
392
|
-
const commandName = parsed.args[0];
|
|
393
|
-
if (command.isMatched(commandName)) {
|
|
394
|
-
shouldParse = false;
|
|
395
|
-
const parsedInfo = __assign(__assign({}, parsed), {
|
|
396
|
-
args: parsed.args.slice(1)
|
|
397
|
-
});
|
|
398
|
-
this.setParsedInfo(parsedInfo, command, commandName);
|
|
399
|
-
this.emit(`command:${commandName}`, command);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
if (shouldParse) {
|
|
403
|
-
for (const command of this.commands)if ("" === command.name) {
|
|
404
|
-
shouldParse = false;
|
|
405
|
-
const parsed = this.mri(argv.slice(2), command);
|
|
406
|
-
this.setParsedInfo(parsed, command);
|
|
407
|
-
this.emit("command:!", command);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
if (shouldParse) {
|
|
411
|
-
const parsed = this.mri(argv.slice(2));
|
|
412
|
-
this.setParsedInfo(parsed);
|
|
413
|
-
}
|
|
414
|
-
if (this.options.help && this.showHelpOnExit) {
|
|
415
|
-
this.outputHelp();
|
|
416
|
-
run = false;
|
|
417
|
-
this.unsetMatchedCommand();
|
|
418
|
-
}
|
|
419
|
-
if (this.options.version && this.showVersionOnExit && null == this.matchedCommandName) {
|
|
420
|
-
this.outputVersion();
|
|
421
|
-
run = false;
|
|
422
|
-
this.unsetMatchedCommand();
|
|
423
|
-
}
|
|
424
|
-
const parsedArgv = {
|
|
425
|
-
args: this.args,
|
|
426
|
-
options: this.options
|
|
427
|
-
};
|
|
428
|
-
if (run) this.runMatchedCommand();
|
|
429
|
-
if (!this.matchedCommand && this.args[0]) this.emit("command:*");
|
|
430
|
-
return parsedArgv;
|
|
431
|
-
}
|
|
432
|
-
mri(argv, command) {
|
|
433
|
-
const cliOptions = [
|
|
434
|
-
...this.globalCommand.options,
|
|
435
|
-
...command ? command.options : []
|
|
436
|
-
];
|
|
437
|
-
const mriOptions = getMriOptions(cliOptions);
|
|
438
|
-
let argsAfterDoubleDashes = [];
|
|
439
|
-
const doubleDashesIndex = argv.indexOf("--");
|
|
440
|
-
if (doubleDashesIndex > -1) {
|
|
441
|
-
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
442
|
-
argv = argv.slice(0, doubleDashesIndex);
|
|
443
|
-
}
|
|
444
|
-
let parsed = mri2(argv, mriOptions);
|
|
445
|
-
parsed = Object.keys(parsed).reduce((res, name)=>__assign(__assign({}, res), {
|
|
446
|
-
[camelcaseOptionName(name)]: parsed[name]
|
|
447
|
-
}), {
|
|
448
|
-
_: []
|
|
449
|
-
});
|
|
450
|
-
const args = parsed._;
|
|
451
|
-
const options = {
|
|
452
|
-
"--": argsAfterDoubleDashes
|
|
453
|
-
};
|
|
454
|
-
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
455
|
-
let transforms = Object.create(null);
|
|
456
|
-
for (const cliOption of cliOptions){
|
|
457
|
-
if (!ignoreDefault && void 0 !== cliOption.config.default) for (const name of cliOption.names)options[name] = cliOption.config.default;
|
|
458
|
-
if (Array.isArray(cliOption.config.type)) {
|
|
459
|
-
if (void 0 === transforms[cliOption.name]) {
|
|
460
|
-
transforms[cliOption.name] = Object.create(null);
|
|
461
|
-
transforms[cliOption.name]["shouldTransform"] = true;
|
|
462
|
-
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
for (const key of Object.keys(parsed))if ("_" !== key) {
|
|
467
|
-
const keys = key.split(".");
|
|
468
|
-
setDotProp(options, keys, parsed[key]);
|
|
469
|
-
setByType(options, transforms);
|
|
470
|
-
}
|
|
471
|
-
return {
|
|
472
|
-
args,
|
|
473
|
-
options
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
runMatchedCommand() {
|
|
477
|
-
const { args, options, matchedCommand: command } = this;
|
|
478
|
-
if (!command || !command.commandAction) return;
|
|
479
|
-
command.checkUnknownOptions();
|
|
480
|
-
command.checkOptionValue();
|
|
481
|
-
command.checkRequiredArgs();
|
|
482
|
-
const actionArgs = [];
|
|
483
|
-
command.args.forEach((arg, index)=>{
|
|
484
|
-
if (arg.variadic) actionArgs.push(args.slice(index));
|
|
485
|
-
else actionArgs.push(args[index]);
|
|
486
|
-
});
|
|
487
|
-
actionArgs.push(options);
|
|
488
|
-
return command.commandAction.apply(this, actionArgs);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
const cac = (name = "")=>new CAC(name);
|
|
492
|
-
const dist = cac;
|
|
493
|
-
function initNodeEnv() {
|
|
494
|
-
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'test';
|
|
495
|
-
}
|
|
496
|
-
function prepareCli() {
|
|
497
|
-
initNodeEnv();
|
|
498
|
-
process.env.RSTEST = 'true';
|
|
499
|
-
const { npm_execpath } = process.env;
|
|
500
|
-
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
501
|
-
}
|
|
502
|
-
function showRstest() {
|
|
503
|
-
src_logger.greet(" Rstest v0.6.5");
|
|
504
|
-
src_logger.log('');
|
|
505
|
-
}
|
|
506
|
-
const applyCommonOptions = (cli)=>{
|
|
507
|
-
cli.option('-c, --config <config>', 'Specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'Specify the loader to load the config file, can be `jiti` or `native`', {
|
|
508
|
-
default: 'jiti'
|
|
509
|
-
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--coverage', 'Enable code coverage collection').option('--project <name>', 'Run only projects that match the name, can be a full name or wildcards pattern').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--logHeapUsage', 'Log heap usage after each test').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('--reporter <reporter>', 'Specify the reporter to use').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--hideSkippedTests', 'Hide skipped tests from the output').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--bail <number>', 'Stop running tests after n failures. Set to 0 to run all tests regardless of failures').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
510
|
-
};
|
|
511
|
-
const runRest = async ({ options, filters, command })=>{
|
|
512
|
-
let rstest;
|
|
513
|
-
try {
|
|
514
|
-
const { initCli } = await Promise.resolve().then(()=>({
|
|
515
|
-
initCli: init_initCli
|
|
516
|
-
}));
|
|
517
|
-
const { config, configFilePath, projects } = await initCli(options);
|
|
518
|
-
const { createRstest } = await Promise.resolve().then(()=>({
|
|
519
|
-
createRstest: core_createRstest
|
|
520
|
-
}));
|
|
521
|
-
rstest = createRstest({
|
|
522
|
-
config,
|
|
523
|
-
configFilePath,
|
|
524
|
-
projects
|
|
525
|
-
}, command, filters.map(normalize));
|
|
526
|
-
if ('watch' === command && configFilePath) {
|
|
527
|
-
const { watchFilesForRestart } = await import("./0~365.js").then((mod)=>({
|
|
528
|
-
watchFilesForRestart: mod.watchFilesForRestart
|
|
529
|
-
}));
|
|
530
|
-
watchFilesForRestart({
|
|
531
|
-
rstest,
|
|
532
|
-
options,
|
|
533
|
-
filters
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
await rstest.runTests();
|
|
537
|
-
} catch (err) {
|
|
538
|
-
for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
|
|
539
|
-
src_logger.error('Failed to run Rstest.');
|
|
540
|
-
src_logger.error(formatError(err));
|
|
541
|
-
process.exit(1);
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
function setupCommands() {
|
|
545
|
-
const cli = dist('rstest');
|
|
546
|
-
cli.help();
|
|
547
|
-
cli.version("0.6.5");
|
|
548
|
-
applyCommonOptions(cli);
|
|
549
|
-
cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
550
|
-
showRstest();
|
|
551
|
-
if (options.watch) await runRest({
|
|
552
|
-
options,
|
|
553
|
-
filters,
|
|
554
|
-
command: 'watch'
|
|
555
|
-
});
|
|
556
|
-
else await runRest({
|
|
557
|
-
options,
|
|
558
|
-
filters,
|
|
559
|
-
command: 'run'
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
cli.command('run [...filters]', 'run tests without watch mode').action(async (filters, options)=>{
|
|
563
|
-
showRstest();
|
|
564
|
-
await runRest({
|
|
565
|
-
options,
|
|
566
|
-
filters,
|
|
567
|
-
command: 'run'
|
|
568
|
-
});
|
|
569
|
-
});
|
|
570
|
-
cli.command('watch [...filters]', 'run tests in watch mode').action(async (filters, options)=>{
|
|
571
|
-
showRstest();
|
|
572
|
-
await runRest({
|
|
573
|
-
options,
|
|
574
|
-
filters,
|
|
575
|
-
command: 'watch'
|
|
576
|
-
});
|
|
577
|
-
});
|
|
578
|
-
cli.command('list [...filters]', 'lists all test files that Rstest will run').option('--filesOnly', 'only list the test files').option('--json [boolean/path]', 'print tests as JSON or write to a file').action(async (filters, options)=>{
|
|
579
|
-
try {
|
|
580
|
-
const { initCli } = await Promise.resolve().then(()=>({
|
|
581
|
-
initCli: init_initCli
|
|
582
|
-
}));
|
|
583
|
-
const { config, configFilePath, projects } = await initCli(options);
|
|
584
|
-
const { createRstest } = await Promise.resolve().then(()=>({
|
|
585
|
-
createRstest: core_createRstest
|
|
586
|
-
}));
|
|
587
|
-
const rstest = createRstest({
|
|
588
|
-
config,
|
|
589
|
-
configFilePath,
|
|
590
|
-
projects
|
|
591
|
-
}, 'list', filters.map(normalize));
|
|
592
|
-
await rstest.listTests({
|
|
593
|
-
filesOnly: options.filesOnly,
|
|
594
|
-
json: options.json
|
|
595
|
-
});
|
|
596
|
-
} catch (err) {
|
|
597
|
-
src_logger.error('Failed to run Rstest list.');
|
|
598
|
-
src_logger.error(formatError(err));
|
|
599
|
-
process.exit(1);
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
cli.parse();
|
|
603
|
-
}
|
|
604
|
-
const external_node_fs_ = __webpack_require__("node:fs");
|
|
605
|
-
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
606
|
-
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
607
|
-
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
|
|
608
|
-
const resolveConfigPath = (root, customConfig)=>{
|
|
609
|
-
if (customConfig) {
|
|
610
|
-
const customConfigPath = isAbsolute(customConfig) ? customConfig : join(root, customConfig);
|
|
611
|
-
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
612
|
-
throw `Cannot find config file: ${picocolors_default().dim(customConfigPath)}`;
|
|
613
|
-
}
|
|
614
|
-
const configFilePath = findConfig(join(root, DEFAULT_CONFIG_NAME));
|
|
615
|
-
if (configFilePath) return configFilePath;
|
|
616
|
-
return null;
|
|
617
|
-
};
|
|
618
|
-
async function config_loadConfig({ cwd = process.cwd(), path, envMode, configLoader }) {
|
|
619
|
-
const configFilePath = resolveConfigPath(cwd, path);
|
|
620
|
-
if (!configFilePath) {
|
|
621
|
-
src_logger.debug('no rstest config file found');
|
|
622
|
-
return {
|
|
623
|
-
content: {},
|
|
624
|
-
filePath: configFilePath
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
const { content } = await loadConfig({
|
|
628
|
-
cwd: dirname(configFilePath),
|
|
629
|
-
path: configFilePath,
|
|
630
|
-
envMode,
|
|
631
|
-
loader: configLoader
|
|
632
|
-
});
|
|
633
|
-
return {
|
|
634
|
-
content: content,
|
|
635
|
-
filePath: configFilePath
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
const mergeRstestConfig = (...configs)=>configs.reduce((result, config)=>{
|
|
639
|
-
const merged = mergeRsbuildConfig(result, {
|
|
640
|
-
...config,
|
|
641
|
-
exclude: Array.isArray(config.exclude) ? {
|
|
642
|
-
patterns: config.exclude,
|
|
643
|
-
override: false
|
|
644
|
-
} : config.exclude
|
|
645
|
-
});
|
|
646
|
-
if (!Array.isArray(config.exclude) && config.exclude?.override) merged.exclude = {
|
|
647
|
-
patterns: config.exclude.patterns
|
|
648
|
-
};
|
|
649
|
-
merged.include = config.include ?? merged.include;
|
|
650
|
-
merged.reporters = config.reporters ?? merged.reporters;
|
|
651
|
-
if (merged.coverage) merged.coverage.reporters = config.coverage?.reporters ?? merged.coverage?.reporters;
|
|
652
|
-
return merged;
|
|
653
|
-
}, {});
|
|
654
|
-
const createDefaultConfig = ()=>({
|
|
655
|
-
root: process.cwd(),
|
|
656
|
-
name: 'rstest',
|
|
657
|
-
include: [
|
|
658
|
-
'**/*.{test,spec}.?(c|m)[jt]s?(x)'
|
|
659
|
-
],
|
|
660
|
-
exclude: {
|
|
661
|
-
patterns: [
|
|
662
|
-
'**/node_modules/**',
|
|
663
|
-
'**/dist/**',
|
|
664
|
-
'**/.{idea,git,cache,output,temp}/**'
|
|
665
|
-
],
|
|
666
|
-
override: false
|
|
667
|
-
},
|
|
668
|
-
setupFiles: [],
|
|
669
|
-
includeSource: [],
|
|
670
|
-
pool: {
|
|
671
|
-
type: 'forks'
|
|
672
|
-
},
|
|
673
|
-
isolate: true,
|
|
674
|
-
globals: false,
|
|
675
|
-
passWithNoTests: false,
|
|
676
|
-
update: false,
|
|
677
|
-
testTimeout: 5000,
|
|
678
|
-
hookTimeout: 10000,
|
|
679
|
-
testEnvironment: 'node',
|
|
680
|
-
retry: 0,
|
|
681
|
-
reporters: 'true' === process.env.GITHUB_ACTIONS ? [
|
|
682
|
-
'default',
|
|
683
|
-
'github-actions'
|
|
684
|
-
] : [
|
|
685
|
-
'default'
|
|
686
|
-
],
|
|
687
|
-
clearMocks: false,
|
|
688
|
-
resetMocks: false,
|
|
689
|
-
restoreMocks: false,
|
|
690
|
-
slowTestThreshold: 300,
|
|
691
|
-
unstubGlobals: false,
|
|
692
|
-
unstubEnvs: false,
|
|
693
|
-
maxConcurrency: 5,
|
|
694
|
-
printConsoleTrace: false,
|
|
695
|
-
disableConsoleIntercept: false,
|
|
696
|
-
snapshotFormat: {},
|
|
697
|
-
env: {},
|
|
698
|
-
hideSkippedTests: false,
|
|
699
|
-
logHeapUsage: false,
|
|
700
|
-
bail: 0,
|
|
701
|
-
coverage: {
|
|
702
|
-
exclude: [
|
|
703
|
-
'**/node_modules/**',
|
|
704
|
-
'**/[.]*',
|
|
705
|
-
'**/dist/**',
|
|
706
|
-
'**/test/**',
|
|
707
|
-
'**/__tests__/**',
|
|
708
|
-
'**/__mocks__/**',
|
|
709
|
-
'**/*.d.ts',
|
|
710
|
-
'**/*.{test,spec}.[jt]s',
|
|
711
|
-
'**/*.{test,spec}.[cm][jt]s',
|
|
712
|
-
'**/*.{test,spec}.[jt]sx',
|
|
713
|
-
'**/*.{test,spec}.[cm][jt]sx'
|
|
714
|
-
],
|
|
715
|
-
enabled: false,
|
|
716
|
-
provider: 'istanbul',
|
|
717
|
-
reporters: [
|
|
718
|
-
'text',
|
|
719
|
-
'html',
|
|
720
|
-
'clover',
|
|
721
|
-
'json'
|
|
722
|
-
],
|
|
723
|
-
reportsDirectory: './coverage',
|
|
724
|
-
clean: true,
|
|
725
|
-
reportOnFailure: false
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
const withDefaultConfig = (config)=>{
|
|
729
|
-
const merged = mergeRstestConfig(createDefaultConfig(), config);
|
|
730
|
-
merged.setupFiles = castArray(merged.setupFiles);
|
|
731
|
-
merged.exclude.patterns.push(TEMP_RSTEST_OUTPUT_DIR_GLOB);
|
|
732
|
-
const reportsDirectory = formatRootStr(merged.coverage.reportsDirectory, merged.root);
|
|
733
|
-
merged.coverage.reportsDirectory = isAbsolute(reportsDirectory) ? reportsDirectory : pathe_M_eThtNZ_resolve(merged.root, reportsDirectory);
|
|
734
|
-
merged.pool = 'string' == typeof config.pool ? {
|
|
735
|
-
type: config.pool
|
|
736
|
-
} : merged.pool;
|
|
737
|
-
return {
|
|
738
|
-
...merged,
|
|
739
|
-
include: merged.include.map((p)=>formatRootStr(p, merged.root)),
|
|
740
|
-
exclude: {
|
|
741
|
-
...merged.exclude,
|
|
742
|
-
patterns: merged.exclude.patterns.map((p)=>formatRootStr(p, merged.root))
|
|
743
|
-
},
|
|
744
|
-
setupFiles: merged.setupFiles.map((p)=>formatRootStr(p, merged.root)),
|
|
745
|
-
includeSource: merged.includeSource.map((p)=>formatRootStr(p, merged.root))
|
|
746
|
-
};
|
|
747
|
-
};
|
|
748
|
-
async function resolveConfig(options) {
|
|
749
|
-
const { content: config, filePath: configFilePath } = await config_loadConfig({
|
|
750
|
-
cwd: options.root,
|
|
751
|
-
path: options.config,
|
|
752
|
-
configLoader: options.configLoader
|
|
753
|
-
});
|
|
754
|
-
const keys = [
|
|
755
|
-
'root',
|
|
756
|
-
'globals',
|
|
757
|
-
'isolate',
|
|
758
|
-
'passWithNoTests',
|
|
759
|
-
'update',
|
|
760
|
-
'testNamePattern',
|
|
761
|
-
'testTimeout',
|
|
762
|
-
'hookTimeout',
|
|
763
|
-
'clearMocks',
|
|
764
|
-
'resetMocks',
|
|
765
|
-
'restoreMocks',
|
|
766
|
-
'unstubEnvs',
|
|
767
|
-
'unstubGlobals',
|
|
768
|
-
'retry',
|
|
769
|
-
'slowTestThreshold',
|
|
770
|
-
'maxConcurrency',
|
|
771
|
-
'printConsoleTrace',
|
|
772
|
-
'disableConsoleIntercept',
|
|
773
|
-
'testEnvironment',
|
|
774
|
-
'hideSkippedTests',
|
|
775
|
-
'logHeapUsage',
|
|
776
|
-
'bail'
|
|
777
|
-
];
|
|
778
|
-
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
779
|
-
if (options.reporter) config.reporters = castArray(options.reporter);
|
|
780
|
-
if (void 0 !== options.coverage) {
|
|
781
|
-
config.coverage ??= {};
|
|
782
|
-
config.coverage.enabled = options.coverage;
|
|
783
|
-
}
|
|
784
|
-
if (options.exclude) config.exclude = castArray(options.exclude);
|
|
785
|
-
if (options.include) config.include = castArray(options.include);
|
|
786
|
-
return {
|
|
787
|
-
config,
|
|
788
|
-
configFilePath: configFilePath ?? void 0
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
async function resolveProjects({ config, root, options }) {
|
|
792
|
-
if (!config.projects) return [];
|
|
793
|
-
const getDefaultProjectName = (dir)=>{
|
|
794
|
-
const pkgJsonPath = pathe_M_eThtNZ_resolve(dir, 'package.json');
|
|
795
|
-
const name = (0, external_node_fs_.existsSync)(pkgJsonPath) ? JSON.parse((0, external_node_fs_.readFileSync)(pkgJsonPath, 'utf-8')).name : '';
|
|
796
|
-
if ('string' != typeof name || !name) return basename(dir);
|
|
797
|
-
return name;
|
|
798
|
-
};
|
|
799
|
-
const globProjects = async (patterns)=>{
|
|
800
|
-
const globOptions = {
|
|
801
|
-
absolute: true,
|
|
802
|
-
dot: true,
|
|
803
|
-
onlyFiles: false,
|
|
804
|
-
cwd: root,
|
|
805
|
-
expandDirectories: false,
|
|
806
|
-
ignore: [
|
|
807
|
-
'**/node_modules/**',
|
|
808
|
-
'**/.DS_Store'
|
|
809
|
-
]
|
|
810
|
-
};
|
|
811
|
-
return glob(patterns, globOptions);
|
|
812
|
-
};
|
|
813
|
-
const { projectPaths, projectPatterns, projectConfigs } = (config.projects || []).reduce((total, p)=>{
|
|
814
|
-
if ('object' == typeof p) {
|
|
815
|
-
const projectRoot = p.root ? formatRootStr(p.root, root) : root;
|
|
816
|
-
total.projectConfigs.push({
|
|
817
|
-
config: {
|
|
818
|
-
root: projectRoot,
|
|
819
|
-
name: p.name ? p.name : getDefaultProjectName(projectRoot),
|
|
820
|
-
...p
|
|
821
|
-
},
|
|
822
|
-
configFilePath: void 0
|
|
823
|
-
});
|
|
824
|
-
return total;
|
|
825
|
-
}
|
|
826
|
-
const projectStr = formatRootStr(p, root);
|
|
827
|
-
if (isDynamicPattern(projectStr)) total.projectPatterns.push(projectStr);
|
|
828
|
-
else {
|
|
829
|
-
const absolutePath = getAbsolutePath(root, projectStr);
|
|
830
|
-
if (!(0, external_node_fs_.existsSync)(absolutePath)) throw `Can't resolve project "${p}", please make sure "${p}" is a existing file or a directory.`;
|
|
831
|
-
total.projectPaths.push(absolutePath);
|
|
832
|
-
}
|
|
833
|
-
return total;
|
|
834
|
-
}, {
|
|
835
|
-
projectPaths: [],
|
|
836
|
-
projectPatterns: [],
|
|
837
|
-
projectConfigs: []
|
|
838
|
-
});
|
|
839
|
-
projectPaths.push(...await globProjects(projectPatterns));
|
|
840
|
-
const projects = await Promise.all(projectPaths.map(async (project)=>{
|
|
841
|
-
const isDirectory = (0, external_node_fs_.statSync)(project).isDirectory();
|
|
842
|
-
const root = isDirectory ? project : dirname(project);
|
|
843
|
-
const { config, configFilePath } = await resolveConfig({
|
|
844
|
-
...options,
|
|
845
|
-
config: isDirectory ? void 0 : project,
|
|
846
|
-
root
|
|
847
|
-
});
|
|
848
|
-
config.name ??= getDefaultProjectName(root);
|
|
849
|
-
if (config.projects?.length && config.root !== root) src_logger.warn(`Projects cannot have nested projects, the "projects" field in project "${config.name}" will be ignored.`);
|
|
850
|
-
return {
|
|
851
|
-
config,
|
|
852
|
-
configFilePath
|
|
853
|
-
};
|
|
854
|
-
})).then((projects)=>filterProjects(projects.concat(projectConfigs), options));
|
|
855
|
-
if (!projects.length) {
|
|
856
|
-
let errorMsg = `No projects found, please make sure you have at least one valid project.
|
|
857
|
-
${picocolors_default().gray('projects:')} ${JSON.stringify(config.projects, null, 2)}`;
|
|
858
|
-
if (options.project) errorMsg += `\n${picocolors_default().gray('projectName filter:')} ${JSON.stringify(options.project, null, 2)}`;
|
|
859
|
-
throw errorMsg;
|
|
860
|
-
}
|
|
861
|
-
const names = new Set();
|
|
862
|
-
projects.forEach((project)=>{
|
|
863
|
-
if (names.has(project.config.name)) {
|
|
864
|
-
const conflictProjects = projects.filter((p)=>p.config.name === project.config.name);
|
|
865
|
-
throw `Project name "${project.config.name}" is already used. Please ensure all projects have unique names.
|
|
866
|
-
Conflicting projects:
|
|
867
|
-
${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')}
|
|
868
|
-
`;
|
|
869
|
-
}
|
|
870
|
-
names.add(project.config.name);
|
|
871
|
-
});
|
|
872
|
-
return projects;
|
|
873
|
-
}
|
|
874
|
-
async function init_initCli(options) {
|
|
875
|
-
const cwd = process.cwd();
|
|
876
|
-
const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
|
|
877
|
-
const { config, configFilePath } = await resolveConfig({
|
|
878
|
-
...options,
|
|
879
|
-
root
|
|
880
|
-
});
|
|
881
|
-
const projects = await resolveProjects({
|
|
882
|
-
config,
|
|
883
|
-
root,
|
|
884
|
-
options
|
|
885
|
-
});
|
|
886
|
-
return {
|
|
887
|
-
config,
|
|
888
|
-
configFilePath,
|
|
889
|
-
projects
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
async function runCLI() {
|
|
893
|
-
prepareCli();
|
|
894
|
-
try {
|
|
895
|
-
setupCommands();
|
|
896
|
-
} catch (err) {
|
|
897
|
-
src_logger.error('Failed to start Rstest CLI.');
|
|
898
|
-
src_logger.error(err);
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
class SnapshotManager {
|
|
902
|
-
summary;
|
|
903
|
-
extension = ".snap";
|
|
904
|
-
constructor(options){
|
|
905
|
-
this.options = options;
|
|
906
|
-
this.clear();
|
|
907
|
-
}
|
|
908
|
-
clear() {
|
|
909
|
-
this.summary = emptySummary(this.options);
|
|
910
|
-
}
|
|
911
|
-
add(result) {
|
|
912
|
-
addSnapshotResult(this.summary, result);
|
|
913
|
-
}
|
|
914
|
-
resolvePath(testPath, context) {
|
|
915
|
-
const resolver = this.options.resolveSnapshotPath || (()=>join(join(dirname(testPath), "__snapshots__"), `${basename(testPath)}${this.extension}`));
|
|
916
|
-
const path = resolver(testPath, this.extension, context);
|
|
917
|
-
return path;
|
|
918
|
-
}
|
|
919
|
-
resolveRawPath(testPath, rawPath) {
|
|
920
|
-
return isAbsolute(rawPath) ? rawPath : pathe_M_eThtNZ_resolve(dirname(testPath), rawPath);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
function emptySummary(options) {
|
|
924
|
-
const summary = {
|
|
925
|
-
added: 0,
|
|
926
|
-
failure: false,
|
|
927
|
-
filesAdded: 0,
|
|
928
|
-
filesRemoved: 0,
|
|
929
|
-
filesRemovedList: [],
|
|
930
|
-
filesUnmatched: 0,
|
|
931
|
-
filesUpdated: 0,
|
|
932
|
-
matched: 0,
|
|
933
|
-
total: 0,
|
|
934
|
-
unchecked: 0,
|
|
935
|
-
uncheckedKeysByFile: [],
|
|
936
|
-
unmatched: 0,
|
|
937
|
-
updated: 0,
|
|
938
|
-
didUpdate: "all" === options.updateSnapshot
|
|
939
|
-
};
|
|
940
|
-
return summary;
|
|
941
|
-
}
|
|
942
|
-
function addSnapshotResult(summary, result) {
|
|
943
|
-
if (result.added) summary.filesAdded++;
|
|
944
|
-
if (result.fileDeleted) summary.filesRemoved++;
|
|
945
|
-
if (result.unmatched) summary.filesUnmatched++;
|
|
946
|
-
if (result.updated) summary.filesUpdated++;
|
|
947
|
-
summary.added += result.added;
|
|
948
|
-
summary.matched += result.matched;
|
|
949
|
-
summary.unchecked += result.unchecked;
|
|
950
|
-
if (result.uncheckedKeys && result.uncheckedKeys.length > 0) summary.uncheckedKeysByFile.push({
|
|
951
|
-
filePath: result.filepath,
|
|
952
|
-
keys: result.uncheckedKeys
|
|
953
|
-
});
|
|
954
|
-
summary.unmatched += result.unmatched;
|
|
955
|
-
summary.updated += result.updated;
|
|
956
|
-
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
|
957
|
-
}
|
|
958
|
-
const dist_r = Object.create(null), dist_i = (e)=>globalThis.process?.env || {
|
|
959
|
-
MODE: "production",
|
|
960
|
-
DEV: false,
|
|
961
|
-
PROD: true,
|
|
962
|
-
BASE_URL: "/",
|
|
963
|
-
ASSET_PREFIX: "auto"
|
|
964
|
-
}, dist_o = new Proxy(dist_r, {
|
|
965
|
-
get (e, s) {
|
|
966
|
-
return dist_i()[s] ?? dist_r[s];
|
|
967
|
-
},
|
|
968
|
-
has (e, s) {
|
|
969
|
-
const E = dist_i();
|
|
970
|
-
return s in E || s in dist_r;
|
|
971
|
-
},
|
|
972
|
-
set (e, s, E) {
|
|
973
|
-
const B = dist_i(!0);
|
|
974
|
-
return B[s] = E, !0;
|
|
975
|
-
},
|
|
976
|
-
deleteProperty (e, s) {
|
|
977
|
-
if (!s) return !1;
|
|
978
|
-
const E = dist_i(!0);
|
|
979
|
-
return delete E[s], !0;
|
|
980
|
-
},
|
|
981
|
-
ownKeys () {
|
|
982
|
-
const e = dist_i(!0);
|
|
983
|
-
return Object.keys(e);
|
|
984
|
-
}
|
|
985
|
-
}), dist_t = typeof process < "u" && process.env && process.env.NODE_ENV || "", f = [
|
|
986
|
-
[
|
|
987
|
-
"APPVEYOR"
|
|
988
|
-
],
|
|
989
|
-
[
|
|
990
|
-
"AWS_AMPLIFY",
|
|
991
|
-
"AWS_APP_ID",
|
|
992
|
-
{
|
|
993
|
-
ci: !0
|
|
994
|
-
}
|
|
995
|
-
],
|
|
996
|
-
[
|
|
997
|
-
"AZURE_PIPELINES",
|
|
998
|
-
"SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"
|
|
999
|
-
],
|
|
1000
|
-
[
|
|
1001
|
-
"AZURE_STATIC",
|
|
1002
|
-
"INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"
|
|
1003
|
-
],
|
|
1004
|
-
[
|
|
1005
|
-
"APPCIRCLE",
|
|
1006
|
-
"AC_APPCIRCLE"
|
|
1007
|
-
],
|
|
1008
|
-
[
|
|
1009
|
-
"BAMBOO",
|
|
1010
|
-
"bamboo_planKey"
|
|
1011
|
-
],
|
|
1012
|
-
[
|
|
1013
|
-
"BITBUCKET",
|
|
1014
|
-
"BITBUCKET_COMMIT"
|
|
1015
|
-
],
|
|
1016
|
-
[
|
|
1017
|
-
"BITRISE",
|
|
1018
|
-
"BITRISE_IO"
|
|
1019
|
-
],
|
|
1020
|
-
[
|
|
1021
|
-
"BUDDY",
|
|
1022
|
-
"BUDDY_WORKSPACE_ID"
|
|
1023
|
-
],
|
|
1024
|
-
[
|
|
1025
|
-
"BUILDKITE"
|
|
1026
|
-
],
|
|
1027
|
-
[
|
|
1028
|
-
"CIRCLE",
|
|
1029
|
-
"CIRCLECI"
|
|
1030
|
-
],
|
|
1031
|
-
[
|
|
1032
|
-
"CIRRUS",
|
|
1033
|
-
"CIRRUS_CI"
|
|
1034
|
-
],
|
|
1035
|
-
[
|
|
1036
|
-
"CLOUDFLARE_PAGES",
|
|
1037
|
-
"CF_PAGES",
|
|
1038
|
-
{
|
|
1039
|
-
ci: !0
|
|
1040
|
-
}
|
|
1041
|
-
],
|
|
1042
|
-
[
|
|
1043
|
-
"CLOUDFLARE_WORKERS",
|
|
1044
|
-
"WORKERS_CI",
|
|
1045
|
-
{
|
|
1046
|
-
ci: !0
|
|
1047
|
-
}
|
|
1048
|
-
],
|
|
1049
|
-
[
|
|
1050
|
-
"CODEBUILD",
|
|
1051
|
-
"CODEBUILD_BUILD_ARN"
|
|
1052
|
-
],
|
|
1053
|
-
[
|
|
1054
|
-
"CODEFRESH",
|
|
1055
|
-
"CF_BUILD_ID"
|
|
1056
|
-
],
|
|
1057
|
-
[
|
|
1058
|
-
"DRONE"
|
|
1059
|
-
],
|
|
1060
|
-
[
|
|
1061
|
-
"DRONE",
|
|
1062
|
-
"DRONE_BUILD_EVENT"
|
|
1063
|
-
],
|
|
1064
|
-
[
|
|
1065
|
-
"DSARI"
|
|
1066
|
-
],
|
|
1067
|
-
[
|
|
1068
|
-
"GITHUB_ACTIONS"
|
|
1069
|
-
],
|
|
1070
|
-
[
|
|
1071
|
-
"GITLAB",
|
|
1072
|
-
"GITLAB_CI"
|
|
1073
|
-
],
|
|
1074
|
-
[
|
|
1075
|
-
"GITLAB",
|
|
1076
|
-
"CI_MERGE_REQUEST_ID"
|
|
1077
|
-
],
|
|
1078
|
-
[
|
|
1079
|
-
"GOCD",
|
|
1080
|
-
"GO_PIPELINE_LABEL"
|
|
1081
|
-
],
|
|
1082
|
-
[
|
|
1083
|
-
"LAYERCI"
|
|
1084
|
-
],
|
|
1085
|
-
[
|
|
1086
|
-
"HUDSON",
|
|
1087
|
-
"HUDSON_URL"
|
|
1088
|
-
],
|
|
1089
|
-
[
|
|
1090
|
-
"JENKINS",
|
|
1091
|
-
"JENKINS_URL"
|
|
1092
|
-
],
|
|
1093
|
-
[
|
|
1094
|
-
"MAGNUM"
|
|
1095
|
-
],
|
|
1096
|
-
[
|
|
1097
|
-
"NETLIFY"
|
|
1098
|
-
],
|
|
1099
|
-
[
|
|
1100
|
-
"NETLIFY",
|
|
1101
|
-
"NETLIFY_LOCAL",
|
|
1102
|
-
{
|
|
1103
|
-
ci: !1
|
|
1104
|
-
}
|
|
1105
|
-
],
|
|
1106
|
-
[
|
|
1107
|
-
"NEVERCODE"
|
|
1108
|
-
],
|
|
1109
|
-
[
|
|
1110
|
-
"RENDER"
|
|
1111
|
-
],
|
|
1112
|
-
[
|
|
1113
|
-
"SAIL",
|
|
1114
|
-
"SAILCI"
|
|
1115
|
-
],
|
|
1116
|
-
[
|
|
1117
|
-
"SEMAPHORE"
|
|
1118
|
-
],
|
|
1119
|
-
[
|
|
1120
|
-
"SCREWDRIVER"
|
|
1121
|
-
],
|
|
1122
|
-
[
|
|
1123
|
-
"SHIPPABLE"
|
|
1124
|
-
],
|
|
1125
|
-
[
|
|
1126
|
-
"SOLANO",
|
|
1127
|
-
"TDDIUM"
|
|
1128
|
-
],
|
|
1129
|
-
[
|
|
1130
|
-
"STRIDER"
|
|
1131
|
-
],
|
|
1132
|
-
[
|
|
1133
|
-
"TEAMCITY",
|
|
1134
|
-
"TEAMCITY_VERSION"
|
|
1135
|
-
],
|
|
1136
|
-
[
|
|
1137
|
-
"TRAVIS"
|
|
1138
|
-
],
|
|
1139
|
-
[
|
|
1140
|
-
"VERCEL",
|
|
1141
|
-
"NOW_BUILDER"
|
|
1142
|
-
],
|
|
1143
|
-
[
|
|
1144
|
-
"VERCEL",
|
|
1145
|
-
"VERCEL",
|
|
1146
|
-
{
|
|
1147
|
-
ci: !1
|
|
1148
|
-
}
|
|
1149
|
-
],
|
|
1150
|
-
[
|
|
1151
|
-
"VERCEL",
|
|
1152
|
-
"VERCEL_ENV",
|
|
1153
|
-
{
|
|
1154
|
-
ci: !1
|
|
1155
|
-
}
|
|
1156
|
-
],
|
|
1157
|
-
[
|
|
1158
|
-
"APPCENTER",
|
|
1159
|
-
"APPCENTER_BUILD_ID"
|
|
1160
|
-
],
|
|
1161
|
-
[
|
|
1162
|
-
"CODESANDBOX",
|
|
1163
|
-
"CODESANDBOX_SSE",
|
|
1164
|
-
{
|
|
1165
|
-
ci: !1
|
|
1166
|
-
}
|
|
1167
|
-
],
|
|
1168
|
-
[
|
|
1169
|
-
"CODESANDBOX",
|
|
1170
|
-
"CODESANDBOX_HOST",
|
|
1171
|
-
{
|
|
1172
|
-
ci: !1
|
|
1173
|
-
}
|
|
1174
|
-
],
|
|
1175
|
-
[
|
|
1176
|
-
"STACKBLITZ"
|
|
1177
|
-
],
|
|
1178
|
-
[
|
|
1179
|
-
"STORMKIT"
|
|
1180
|
-
],
|
|
1181
|
-
[
|
|
1182
|
-
"CLEAVR"
|
|
1183
|
-
],
|
|
1184
|
-
[
|
|
1185
|
-
"ZEABUR"
|
|
1186
|
-
],
|
|
1187
|
-
[
|
|
1188
|
-
"CODESPHERE",
|
|
1189
|
-
"CODESPHERE_APP_ID",
|
|
1190
|
-
{
|
|
1191
|
-
ci: !0
|
|
1192
|
-
}
|
|
1193
|
-
],
|
|
1194
|
-
[
|
|
1195
|
-
"RAILWAY",
|
|
1196
|
-
"RAILWAY_PROJECT_ID"
|
|
1197
|
-
],
|
|
1198
|
-
[
|
|
1199
|
-
"RAILWAY",
|
|
1200
|
-
"RAILWAY_SERVICE_ID"
|
|
1201
|
-
],
|
|
1202
|
-
[
|
|
1203
|
-
"DENO-DEPLOY",
|
|
1204
|
-
"DENO_DEPLOYMENT_ID"
|
|
1205
|
-
],
|
|
1206
|
-
[
|
|
1207
|
-
"FIREBASE_APP_HOSTING",
|
|
1208
|
-
"FIREBASE_APP_HOSTING",
|
|
1209
|
-
{
|
|
1210
|
-
ci: !0
|
|
1211
|
-
}
|
|
1212
|
-
]
|
|
1213
|
-
];
|
|
1214
|
-
function dist_b() {
|
|
1215
|
-
if (globalThis.process?.env) for (const e of f){
|
|
1216
|
-
const s = e[1] || e[0];
|
|
1217
|
-
if (globalThis.process?.env[s]) return {
|
|
1218
|
-
name: e[0].toLowerCase(),
|
|
1219
|
-
...e[2]
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
|
|
1223
|
-
name: "stackblitz",
|
|
1224
|
-
ci: !1
|
|
1225
|
-
} : {
|
|
1226
|
-
name: "",
|
|
1227
|
-
ci: !1
|
|
1228
|
-
};
|
|
1229
|
-
}
|
|
1230
|
-
const l = dist_b();
|
|
1231
|
-
l.name;
|
|
1232
|
-
function n(e) {
|
|
1233
|
-
return e ? "false" !== e : !1;
|
|
1234
|
-
}
|
|
1235
|
-
const I = globalThis.process?.platform || "", T = n(dist_o.CI) || !1 !== l.ci, R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), A = (n(dist_o.DEBUG), "test" === dist_t || n(dist_o.TEST), n(dist_o.MINIMAL), /^win/i.test(I)), C = (/^linux/i.test(I), /^darwin/i.test(I), !n(dist_o.NO_COLOR) && (n(dist_o.FORCE_COLOR) || (R || A) && dist_o.TERM), (globalThis.process?.versions?.node || "").replace(/^v/, "") || null), W = (Number(C?.split(".")[0]), globalThis.process || Object.create(null)), dist_ = {
|
|
1236
|
-
versions: {}
|
|
1237
|
-
}, O = (new Proxy(W, {
|
|
1238
|
-
get (e, s) {
|
|
1239
|
-
if ("env" === s) return dist_o;
|
|
1240
|
-
if (s in e) return e[s];
|
|
1241
|
-
if (s in dist_) return dist_[s];
|
|
1242
|
-
}
|
|
1243
|
-
}), globalThis.process?.release?.name === "node"), c = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
|
|
1244
|
-
[
|
|
1245
|
-
S,
|
|
1246
|
-
"netlify"
|
|
1247
|
-
],
|
|
1248
|
-
[
|
|
1249
|
-
u,
|
|
1250
|
-
"edge-light"
|
|
1251
|
-
],
|
|
1252
|
-
[
|
|
1253
|
-
N,
|
|
1254
|
-
"workerd"
|
|
1255
|
-
],
|
|
1256
|
-
[
|
|
1257
|
-
L,
|
|
1258
|
-
"fastly"
|
|
1259
|
-
],
|
|
1260
|
-
[
|
|
1261
|
-
D,
|
|
1262
|
-
"deno"
|
|
1263
|
-
],
|
|
1264
|
-
[
|
|
1265
|
-
c,
|
|
1266
|
-
"bun"
|
|
1267
|
-
],
|
|
1268
|
-
[
|
|
1269
|
-
O,
|
|
1270
|
-
"node"
|
|
1271
|
-
]
|
|
1272
|
-
];
|
|
1273
|
-
function G() {
|
|
1274
|
-
const e = F.find((s)=>s[0]);
|
|
1275
|
-
if (e) return {
|
|
1276
|
-
name: e[1]
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
const P = G();
|
|
1280
|
-
P?.name;
|
|
1281
|
-
var UNKNOWN_FUNCTION = '<unknown>';
|
|
1282
|
-
function stack_trace_parser_esm_parse(stackString) {
|
|
1283
|
-
var lines = stackString.split('\n');
|
|
1284
|
-
return lines.reduce(function(stack, line) {
|
|
1285
|
-
var parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line);
|
|
1286
|
-
if (parseResult) stack.push(parseResult);
|
|
1287
|
-
return stack;
|
|
1288
|
-
}, []);
|
|
1289
|
-
}
|
|
1290
|
-
var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|rsc|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
1291
|
-
var chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/;
|
|
1292
|
-
function parseChrome(line) {
|
|
1293
|
-
var parts = chromeRe.exec(line);
|
|
1294
|
-
if (!parts) return null;
|
|
1295
|
-
var isNative = parts[2] && 0 === parts[2].indexOf('native');
|
|
1296
|
-
var isEval = parts[2] && 0 === parts[2].indexOf('eval');
|
|
1297
|
-
var submatch = chromeEvalRe.exec(parts[2]);
|
|
1298
|
-
if (isEval && null != submatch) {
|
|
1299
|
-
parts[2] = submatch[1];
|
|
1300
|
-
parts[3] = submatch[2];
|
|
1301
|
-
parts[4] = submatch[3];
|
|
1302
|
-
}
|
|
1303
|
-
return {
|
|
1304
|
-
file: isNative ? null : parts[2],
|
|
1305
|
-
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1306
|
-
arguments: isNative ? [
|
|
1307
|
-
parts[2]
|
|
1308
|
-
] : [],
|
|
1309
|
-
lineNumber: parts[3] ? +parts[3] : null,
|
|
1310
|
-
column: parts[4] ? +parts[4] : null
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|rsc|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1314
|
-
function parseWinjs(line) {
|
|
1315
|
-
var parts = winjsRe.exec(line);
|
|
1316
|
-
if (!parts) return null;
|
|
1317
|
-
return {
|
|
1318
|
-
file: parts[2],
|
|
1319
|
-
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1320
|
-
arguments: [],
|
|
1321
|
-
lineNumber: +parts[3],
|
|
1322
|
-
column: parts[4] ? +parts[4] : null
|
|
1323
|
-
};
|
|
1324
|
-
}
|
|
1325
|
-
var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|rsc|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
1326
|
-
var geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
1327
|
-
function parseGecko(line) {
|
|
1328
|
-
var parts = geckoRe.exec(line);
|
|
1329
|
-
if (!parts) return null;
|
|
1330
|
-
var isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
|
|
1331
|
-
var submatch = geckoEvalRe.exec(parts[3]);
|
|
1332
|
-
if (isEval && null != submatch) {
|
|
1333
|
-
parts[3] = submatch[1];
|
|
1334
|
-
parts[4] = submatch[2];
|
|
1335
|
-
parts[5] = null;
|
|
1336
|
-
}
|
|
1337
|
-
return {
|
|
1338
|
-
file: parts[3],
|
|
1339
|
-
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1340
|
-
arguments: parts[2] ? parts[2].split(',') : [],
|
|
1341
|
-
lineNumber: parts[4] ? +parts[4] : null,
|
|
1342
|
-
column: parts[5] ? +parts[5] : null
|
|
1343
|
-
};
|
|
1344
|
-
}
|
|
1345
|
-
var javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
|
|
1346
|
-
function parseJSC(line) {
|
|
1347
|
-
var parts = javaScriptCoreRe.exec(line);
|
|
1348
|
-
if (!parts) return null;
|
|
1349
|
-
return {
|
|
1350
|
-
file: parts[3],
|
|
1351
|
-
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1352
|
-
arguments: [],
|
|
1353
|
-
lineNumber: +parts[4],
|
|
1354
|
-
column: parts[5] ? +parts[5] : null
|
|
1355
|
-
};
|
|
1356
|
-
}
|
|
1357
|
-
var nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1358
|
-
function parseNode(line) {
|
|
1359
|
-
var parts = nodeRe.exec(line);
|
|
1360
|
-
if (!parts) return null;
|
|
1361
|
-
return {
|
|
1362
|
-
file: parts[2],
|
|
1363
|
-
methodName: parts[1] || UNKNOWN_FUNCTION,
|
|
1364
|
-
arguments: [],
|
|
1365
|
-
lineNumber: +parts[3],
|
|
1366
|
-
column: parts[4] ? +parts[4] : null
|
|
1367
|
-
};
|
|
1368
|
-
}
|
|
1369
|
-
const getSummaryStatusString = (tasks, name = 'tests', showTotal = true)=>{
|
|
1370
|
-
if (0 === tasks.length) return picocolors_default().dim(`no ${name}`);
|
|
1371
|
-
const passed = tasks.filter((result)=>'pass' === result.status);
|
|
1372
|
-
const failed = tasks.filter((result)=>'fail' === result.status);
|
|
1373
|
-
const skipped = tasks.filter((result)=>'skip' === result.status);
|
|
1374
|
-
const todo = tasks.filter((result)=>'todo' === result.status);
|
|
1375
|
-
const status = [
|
|
1376
|
-
failed.length ? picocolors_default().bold(picocolors_default().red(`${failed.length} failed`)) : null,
|
|
1377
|
-
passed.length ? picocolors_default().bold(picocolors_default().green(`${passed.length} passed`)) : null,
|
|
1378
|
-
skipped.length ? picocolors_default().yellow(`${skipped.length} skipped`) : null,
|
|
1379
|
-
todo.length ? picocolors_default().gray(`${todo.length} todo`) : null
|
|
1380
|
-
].filter(Boolean);
|
|
1381
|
-
return status.join(picocolors_default().dim(' | ')) + (showTotal && status.length > 1 ? picocolors_default().gray(` (${tasks.length})`) : '');
|
|
1382
|
-
};
|
|
1383
|
-
const printSnapshotSummaryLog = (snapshots, rootDir)=>{
|
|
1384
|
-
const summary = [];
|
|
1385
|
-
if (snapshots.added) summary.push(picocolors_default().bold(picocolors_default().green(`${snapshots.added} written`)));
|
|
1386
|
-
if (snapshots.unmatched) summary.push(picocolors_default().bold(picocolors_default().red(`${snapshots.unmatched} failed`)));
|
|
1387
|
-
if (snapshots.updated) summary.push(picocolors_default().bold(picocolors_default().green(`${snapshots.updated} updated `)));
|
|
1388
|
-
if (snapshots.filesRemoved) if (snapshots.didUpdate) summary.push(picocolors_default().bold(picocolors_default().green(`${snapshots.filesRemoved} files removed `)));
|
|
1389
|
-
else summary.push(picocolors_default().bold(picocolors_default().yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
1390
|
-
const POINTER = '➜';
|
|
1391
|
-
if (snapshots.filesRemovedList?.length) {
|
|
1392
|
-
const [head, ...tail] = snapshots.filesRemovedList;
|
|
1393
|
-
summary.push(`${picocolors_default().gray(POINTER)} ${formatTestPath(rootDir, head)}`);
|
|
1394
|
-
for (const key of tail)summary.push(` ${formatTestPath(rootDir, key)}`);
|
|
1395
|
-
}
|
|
1396
|
-
if (snapshots.unchecked) {
|
|
1397
|
-
if (snapshots.didUpdate) summary.push(picocolors_default().bold(picocolors_default().green(`${snapshots.unchecked} removed`)));
|
|
1398
|
-
else summary.push(picocolors_default().bold(picocolors_default().yellow(`${snapshots.unchecked} obsolete`)));
|
|
1399
|
-
for (const uncheckedFile of snapshots.uncheckedKeysByFile){
|
|
1400
|
-
summary.push(`${picocolors_default().gray(POINTER)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
|
|
1401
|
-
for (const key of uncheckedFile.keys)summary.push(` ${key}`);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
for (const [index, snapshot] of summary.entries()){
|
|
1405
|
-
const title = 0 === index ? 'Snapshots' : '';
|
|
1406
|
-
src_logger.log(`${picocolors_default().gray(title.padStart(12))} ${snapshot}`);
|
|
1407
|
-
}
|
|
1408
|
-
};
|
|
1409
|
-
const TestFileSummaryLabel = picocolors_default().gray('Test Files'.padStart(11));
|
|
1410
|
-
const TestSummaryLabel = picocolors_default().gray('Tests'.padStart(11));
|
|
1411
|
-
const DurationLabel = picocolors_default().gray('Duration'.padStart(11));
|
|
1412
|
-
const printSummaryLog = ({ results, testResults, snapshotSummary, duration, rootPath })=>{
|
|
1413
|
-
src_logger.log('');
|
|
1414
|
-
printSnapshotSummaryLog(snapshotSummary, rootPath);
|
|
1415
|
-
src_logger.log(`${TestFileSummaryLabel} ${getSummaryStatusString(results)}`);
|
|
1416
|
-
src_logger.log(`${TestSummaryLabel} ${getSummaryStatusString(testResults)}`);
|
|
1417
|
-
src_logger.log(`${DurationLabel} ${prettyTime(duration.totalTime)} ${picocolors_default().gray(`(build ${prettyTime(duration.buildTime)}, tests ${prettyTime(duration.testTime)})`)}`);
|
|
1418
|
-
src_logger.log('');
|
|
1419
|
-
};
|
|
1420
|
-
const printSummaryErrorLogs = async ({ testResults, results, rootPath, getSourcemap, filterRerunTestPaths })=>{
|
|
1421
|
-
const failedTests = [
|
|
1422
|
-
...results.filter((i)=>'fail' === i.status && i.errors?.length && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true)),
|
|
1423
|
-
...testResults.filter((i)=>'fail' === i.status && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true))
|
|
1424
|
-
];
|
|
1425
|
-
if (0 === failedTests.length) return;
|
|
1426
|
-
src_logger.log('');
|
|
1427
|
-
src_logger.log(picocolors_default().bold('Summary of all failing tests:'));
|
|
1428
|
-
src_logger.log('');
|
|
1429
|
-
for (const test of failedTests){
|
|
1430
|
-
const relativePath = posix.relative(rootPath, test.testPath);
|
|
1431
|
-
const nameStr = getTaskNameWithPrefix(test);
|
|
1432
|
-
src_logger.log(`${picocolors_default().bgRed(' FAIL ')} ${prettyTestPath(relativePath)} ${nameStr.length ? `${picocolors_default().dim(">")} ${nameStr}` : ''}`);
|
|
1433
|
-
if (test.errors) {
|
|
1434
|
-
const { printError } = await Promise.resolve().then(()=>({
|
|
1435
|
-
printError: error_printError
|
|
1436
|
-
}));
|
|
1437
|
-
for (const error of test.errors)await printError(error, getSourcemap, rootPath);
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
};
|
|
1441
|
-
const external_node_util_ = __webpack_require__("node:util");
|
|
1442
|
-
const DEFAULT_RENDER_INTERVAL_MS = 1000;
|
|
1443
|
-
const ESC = '\x1B[';
|
|
1444
|
-
const CLEAR_LINE = `${ESC}K`;
|
|
1445
|
-
const MOVE_CURSOR_ONE_ROW_UP = `${ESC}1A`;
|
|
1446
|
-
const SYNC_START = `${ESC}?2026h`;
|
|
1447
|
-
const SYNC_END = `${ESC}?2026l`;
|
|
1448
|
-
class WindowRenderer {
|
|
1449
|
-
options;
|
|
1450
|
-
streams;
|
|
1451
|
-
buffer = [];
|
|
1452
|
-
renderInterval = void 0;
|
|
1453
|
-
renderScheduled = false;
|
|
1454
|
-
windowHeight = 0;
|
|
1455
|
-
finished = false;
|
|
1456
|
-
cleanups = [];
|
|
1457
|
-
constructor(options){
|
|
1458
|
-
this.options = {
|
|
1459
|
-
interval: DEFAULT_RENDER_INTERVAL_MS,
|
|
1460
|
-
...options
|
|
1461
|
-
};
|
|
1462
|
-
this.streams = {
|
|
1463
|
-
output: options.logger.outputStream.write.bind(options.logger.outputStream),
|
|
1464
|
-
error: options.logger.errorStream.write.bind(options.logger.errorStream)
|
|
1465
|
-
};
|
|
1466
|
-
this.cleanups.push(this.interceptStream(process.stdout, 'output'), this.interceptStream(process.stderr, 'error'));
|
|
1467
|
-
this.start();
|
|
1468
|
-
}
|
|
1469
|
-
start() {
|
|
1470
|
-
this.finished = false;
|
|
1471
|
-
this.renderInterval = setInterval(()=>this.schedule(), this.options.interval).unref();
|
|
1472
|
-
}
|
|
1473
|
-
stop() {
|
|
1474
|
-
this.cleanups.splice(0).map((fn)=>fn());
|
|
1475
|
-
clearInterval(this.renderInterval);
|
|
1476
|
-
}
|
|
1477
|
-
finish() {
|
|
1478
|
-
this.finished = true;
|
|
1479
|
-
this.flushBuffer();
|
|
1480
|
-
clearInterval(this.renderInterval);
|
|
1481
|
-
}
|
|
1482
|
-
schedule() {
|
|
1483
|
-
if (!this.renderScheduled) {
|
|
1484
|
-
this.renderScheduled = true;
|
|
1485
|
-
this.flushBuffer();
|
|
1486
|
-
setTimeout(()=>{
|
|
1487
|
-
this.renderScheduled = false;
|
|
1488
|
-
}, 100).unref();
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
flushBuffer() {
|
|
1492
|
-
if (0 === this.buffer.length) return this.render();
|
|
1493
|
-
let current;
|
|
1494
|
-
for (const next of this.buffer.splice(0)){
|
|
1495
|
-
if (!current) {
|
|
1496
|
-
current = next;
|
|
1497
|
-
continue;
|
|
1498
|
-
}
|
|
1499
|
-
if (current.type !== next.type) {
|
|
1500
|
-
this.render(current.message, current.type);
|
|
1501
|
-
current = next;
|
|
1502
|
-
continue;
|
|
1503
|
-
}
|
|
1504
|
-
current.message += next.message;
|
|
1505
|
-
}
|
|
1506
|
-
if (current) this.render(current?.message, current?.type);
|
|
1507
|
-
}
|
|
1508
|
-
render(message, type = 'output') {
|
|
1509
|
-
if (this.finished) {
|
|
1510
|
-
this.clearWindow();
|
|
1511
|
-
return this.write(message || '', type);
|
|
1512
|
-
}
|
|
1513
|
-
const windowContent = this.options.getWindow();
|
|
1514
|
-
const rowCount = getRenderedRowCount(windowContent, this.options.logger.getColumns());
|
|
1515
|
-
let padding = this.windowHeight - rowCount;
|
|
1516
|
-
if (padding > 0 && message) padding -= getRenderedRowCount([
|
|
1517
|
-
message
|
|
1518
|
-
], this.options.logger.getColumns());
|
|
1519
|
-
this.write(SYNC_START);
|
|
1520
|
-
this.clearWindow();
|
|
1521
|
-
if (message) this.write(message, type);
|
|
1522
|
-
if (padding > 0) this.write('\n'.repeat(padding));
|
|
1523
|
-
this.write(windowContent.join('\n'));
|
|
1524
|
-
this.write(SYNC_END);
|
|
1525
|
-
this.windowHeight = rowCount + Math.max(0, padding);
|
|
1526
|
-
}
|
|
1527
|
-
clearWindow() {
|
|
1528
|
-
if (0 === this.windowHeight) return;
|
|
1529
|
-
this.write(CLEAR_LINE);
|
|
1530
|
-
for(let i = 1; i < this.windowHeight; i++)this.write(`${MOVE_CURSOR_ONE_ROW_UP}${CLEAR_LINE}`);
|
|
1531
|
-
this.windowHeight = 0;
|
|
1532
|
-
}
|
|
1533
|
-
interceptStream(stream, type) {
|
|
1534
|
-
const original = stream.write.bind(stream);
|
|
1535
|
-
stream.write = (chunk, _, callback)=>{
|
|
1536
|
-
if (chunk) if (this.finished) this.write(chunk.toString(), type);
|
|
1537
|
-
else this.buffer.push({
|
|
1538
|
-
type,
|
|
1539
|
-
message: chunk.toString()
|
|
1540
|
-
});
|
|
1541
|
-
callback?.();
|
|
1542
|
-
};
|
|
1543
|
-
return function restore() {
|
|
1544
|
-
stream.write = original;
|
|
1545
|
-
};
|
|
1546
|
-
}
|
|
1547
|
-
write(message, type = 'output') {
|
|
1548
|
-
this.streams[type](message);
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
function getRenderedRowCount(rows, columns) {
|
|
1552
|
-
let count = 0;
|
|
1553
|
-
for (const row of rows){
|
|
1554
|
-
const text = (0, external_node_util_.stripVTControlCharacters)(row);
|
|
1555
|
-
count += Math.max(1, Math.ceil(text.length / columns));
|
|
1556
|
-
}
|
|
1557
|
-
return count;
|
|
1558
|
-
}
|
|
1559
|
-
class StatusRenderer {
|
|
1560
|
-
rootPath;
|
|
1561
|
-
renderer;
|
|
1562
|
-
runningModules = new Map();
|
|
1563
|
-
testModules = [];
|
|
1564
|
-
startTime = void 0;
|
|
1565
|
-
constructor(rootPath){
|
|
1566
|
-
this.rootPath = rootPath;
|
|
1567
|
-
this.renderer = new WindowRenderer({
|
|
1568
|
-
getWindow: ()=>this.getContent(),
|
|
1569
|
-
logger: {
|
|
1570
|
-
outputStream: process.stdout,
|
|
1571
|
-
errorStream: process.stderr,
|
|
1572
|
-
getColumns: ()=>'columns' in process.stdout ? process.stdout.columns : 80
|
|
1573
|
-
}
|
|
1574
|
-
});
|
|
1575
|
-
}
|
|
1576
|
-
getContent() {
|
|
1577
|
-
this.startTime ??= Date.now();
|
|
1578
|
-
const summary = [];
|
|
1579
|
-
for (const module of this.runningModules.keys()){
|
|
1580
|
-
const relativePath = pathe_M_eThtNZ_relative(this.rootPath, module);
|
|
1581
|
-
summary.push(`${picocolors_default().bgYellow(picocolors_default().bold(' RUNS '))} ${prettyTestPath(relativePath)}`);
|
|
1582
|
-
}
|
|
1583
|
-
summary.push('');
|
|
1584
|
-
if (0 === this.testModules.length) summary.push(`${TestFileSummaryLabel} ${this.runningModules.size} total`);
|
|
1585
|
-
else summary.push(`${TestFileSummaryLabel} ${getSummaryStatusString(this.testModules, '', false)} ${picocolors_default().dim('|')} ${this.runningModules.size + this.testModules.length} total`);
|
|
1586
|
-
const testResults = Array.from(this.runningModules.values()).flat().concat(this.testModules.flatMap((mod)=>mod.results));
|
|
1587
|
-
if (testResults.length) summary.push(`${TestSummaryLabel} ${getSummaryStatusString(testResults, '', false)}`);
|
|
1588
|
-
summary.push(`${DurationLabel} ${prettyTime(Date.now() - this.startTime)}`);
|
|
1589
|
-
summary.push('');
|
|
1590
|
-
return summary;
|
|
1591
|
-
}
|
|
1592
|
-
onTestFileStart(testPath) {
|
|
1593
|
-
this.runningModules.set(testPath, []);
|
|
1594
|
-
this.renderer?.schedule();
|
|
1595
|
-
}
|
|
1596
|
-
onTestCaseResult(result) {
|
|
1597
|
-
this.runningModules.set(result.testPath, [
|
|
1598
|
-
...this.runningModules.get(result.testPath) || [],
|
|
1599
|
-
result
|
|
1600
|
-
]);
|
|
1601
|
-
}
|
|
1602
|
-
onTestFileResult(test) {
|
|
1603
|
-
this.runningModules.delete(test.testPath);
|
|
1604
|
-
this.testModules.push(test);
|
|
1605
|
-
this.renderer?.schedule();
|
|
1606
|
-
}
|
|
1607
|
-
clear() {
|
|
1608
|
-
this.testModules.length = 0;
|
|
1609
|
-
this.runningModules.clear();
|
|
1610
|
-
this.startTime = void 0;
|
|
1611
|
-
this.renderer?.finish();
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
const statusStr = {
|
|
1615
|
-
fail: '✗',
|
|
1616
|
-
pass: '✓',
|
|
1617
|
-
todo: '-',
|
|
1618
|
-
skip: '-'
|
|
1619
|
-
};
|
|
1620
|
-
const statusColorfulStr = {
|
|
1621
|
-
fail: picocolors_default().red(statusStr.fail),
|
|
1622
|
-
pass: picocolors_default().green(statusStr.pass),
|
|
1623
|
-
todo: picocolors_default().gray(statusStr.todo),
|
|
1624
|
-
skip: picocolors_default().gray(statusStr.skip)
|
|
1625
|
-
};
|
|
1626
|
-
const logCase = (result, options)=>{
|
|
1627
|
-
const isSlowCase = (result.duration || 0) > options.slowTestThreshold;
|
|
1628
|
-
if (options.hideSkippedTests && 'skip' === result.status) return;
|
|
1629
|
-
const icon = isSlowCase && 'pass' === result.status ? picocolors_default().yellow(statusStr[result.status]) : statusColorfulStr[result.status];
|
|
1630
|
-
const nameStr = getTaskNameWithPrefix(result);
|
|
1631
|
-
const duration = void 0 !== result.duration ? ` (${prettyTime(result.duration)})` : '';
|
|
1632
|
-
const retry = result.retryCount ? picocolors_default().yellow(` (retry x${result.retryCount})`) : '';
|
|
1633
|
-
const heap = result.heap ? ` ${picocolors_default().magenta(formatHeapUsed(result.heap))}` : '';
|
|
1634
|
-
src_logger.log(` ${icon} ${nameStr}${picocolors_default().gray(duration)}${retry}${heap}`);
|
|
1635
|
-
if (result.errors) for (const error of result.errors)console.error(picocolors_default().red(` ${error.message}`));
|
|
1636
|
-
};
|
|
1637
|
-
const formatHeapUsed = (heap)=>`${Math.floor(heap / 1024 / 1024)} MB heap used`;
|
|
1638
|
-
const logFileTitle = (test, relativePath, alwaysShowTime = false)=>{
|
|
1639
|
-
let title = ` ${picocolors_default().bold(statusColorfulStr[test.status])} ${prettyTestPath(relativePath)}`;
|
|
1640
|
-
const formatDuration = (duration)=>picocolors_default().green(prettyTime(duration));
|
|
1641
|
-
title += ` ${picocolors_default().gray(`(${test.results.length})`)}`;
|
|
1642
|
-
if (alwaysShowTime) title += ` ${formatDuration(test.duration)}`;
|
|
1643
|
-
if (test.heap) title += ` ${picocolors_default().magenta(formatHeapUsed(test.heap))}`;
|
|
1644
|
-
src_logger.log(title);
|
|
1645
|
-
};
|
|
1646
|
-
class DefaultReporter {
|
|
1647
|
-
rootPath;
|
|
1648
|
-
config;
|
|
1649
|
-
options = {};
|
|
1650
|
-
statusRenderer;
|
|
1651
|
-
constructor({ rootPath, options, config }){
|
|
1652
|
-
this.rootPath = rootPath;
|
|
1653
|
-
this.config = config;
|
|
1654
|
-
this.options = options;
|
|
1655
|
-
if (isTTY()) this.statusRenderer = new StatusRenderer(rootPath);
|
|
1656
|
-
}
|
|
1657
|
-
onTestFileStart(test) {
|
|
1658
|
-
this.statusRenderer?.onTestFileStart(test.testPath);
|
|
1659
|
-
}
|
|
1660
|
-
onTestFileResult(test) {
|
|
1661
|
-
this.statusRenderer?.onTestFileResult(test);
|
|
1662
|
-
const relativePath = pathe_M_eThtNZ_relative(this.rootPath, test.testPath);
|
|
1663
|
-
const { slowTestThreshold } = this.config;
|
|
1664
|
-
logFileTitle(test, relativePath);
|
|
1665
|
-
for (const result of test.results){
|
|
1666
|
-
const isDisplayed = 'fail' === result.status || (result.duration ?? 0) > slowTestThreshold || (result.retryCount ?? 0) > 0;
|
|
1667
|
-
isDisplayed && logCase(result, {
|
|
1668
|
-
slowTestThreshold,
|
|
1669
|
-
hideSkippedTests: this.config.hideSkippedTests
|
|
1670
|
-
});
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
onTestCaseResult(result) {
|
|
1674
|
-
this.statusRenderer?.onTestCaseResult(result);
|
|
1675
|
-
}
|
|
1676
|
-
onUserConsoleLog(log) {
|
|
1677
|
-
const shouldLog = this.config.onConsoleLog?.(log.content) ?? true;
|
|
1678
|
-
if (!shouldLog) return;
|
|
1679
|
-
const titles = [];
|
|
1680
|
-
const testPath = pathe_M_eThtNZ_relative(this.rootPath, log.testPath);
|
|
1681
|
-
if (log.trace) {
|
|
1682
|
-
const [frame] = stack_trace_parser_esm_parse(log.trace);
|
|
1683
|
-
const filePath = pathe_M_eThtNZ_relative(this.rootPath, frame.file || '');
|
|
1684
|
-
if (filePath !== testPath) titles.push(testPath);
|
|
1685
|
-
titles.push(`${filePath}:${frame.lineNumber}:${frame.column}`);
|
|
1686
|
-
} else titles.push(testPath);
|
|
1687
|
-
src_logger.log('');
|
|
1688
|
-
src_logger.log(`${log.name}${picocolors_default().gray(picocolors_default().dim(` | ${titles.join(picocolors_default().gray(picocolors_default().dim(' | ')))}`))}`);
|
|
1689
|
-
src_logger.log(log.content);
|
|
1690
|
-
src_logger.log('');
|
|
1691
|
-
}
|
|
1692
|
-
async onExit() {
|
|
1693
|
-
this.statusRenderer?.clear();
|
|
1694
|
-
}
|
|
1695
|
-
async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths }) {
|
|
1696
|
-
this.statusRenderer?.clear();
|
|
1697
|
-
if (false === this.options.summary) return;
|
|
1698
|
-
await printSummaryErrorLogs({
|
|
1699
|
-
testResults,
|
|
1700
|
-
results,
|
|
1701
|
-
rootPath: this.rootPath,
|
|
1702
|
-
getSourcemap,
|
|
1703
|
-
filterRerunTestPaths
|
|
1704
|
-
});
|
|
1705
|
-
printSummaryLog({
|
|
1706
|
-
results,
|
|
1707
|
-
testResults,
|
|
1708
|
-
duration,
|
|
1709
|
-
rootPath: this.rootPath,
|
|
1710
|
-
snapshotSummary
|
|
1711
|
-
});
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
class GithubActionsReporter {
|
|
1715
|
-
onWritePath;
|
|
1716
|
-
rootPath;
|
|
1717
|
-
constructor({ options, rootPath }){
|
|
1718
|
-
this.onWritePath = options.onWritePath;
|
|
1719
|
-
this.rootPath = rootPath;
|
|
1720
|
-
}
|
|
1721
|
-
log(message) {
|
|
1722
|
-
console.log(`${message}\n`);
|
|
1723
|
-
}
|
|
1724
|
-
async onTestRunEnd({ results, testResults, getSourcemap }) {
|
|
1725
|
-
const failedTests = [
|
|
1726
|
-
...results.filter((i)=>'fail' === i.status && i.errors?.length),
|
|
1727
|
-
...testResults.filter((i)=>'fail' === i.status)
|
|
1728
|
-
];
|
|
1729
|
-
if (0 === failedTests.length) return;
|
|
1730
|
-
const { parseErrorStacktrace } = await Promise.resolve().then(()=>({
|
|
1731
|
-
parseErrorStacktrace: error_parseErrorStacktrace
|
|
1732
|
-
}));
|
|
1733
|
-
const logs = [];
|
|
1734
|
-
for (const test of failedTests){
|
|
1735
|
-
const { testPath } = test;
|
|
1736
|
-
const nameStr = getTaskNameWithPrefix(test);
|
|
1737
|
-
const shortPath = pathe_M_eThtNZ_relative(this.rootPath, testPath);
|
|
1738
|
-
const title = `${shortPath} > ${nameStr}`;
|
|
1739
|
-
for (const error of test.errors || []){
|
|
1740
|
-
let file = testPath;
|
|
1741
|
-
let line = 1;
|
|
1742
|
-
let column = 1;
|
|
1743
|
-
const message = `${error.message}${error.diff ? `\n${error.diff}` : ''}`;
|
|
1744
|
-
const type = 'error';
|
|
1745
|
-
if (error.stack) {
|
|
1746
|
-
const stackFrames = await parseErrorStacktrace({
|
|
1747
|
-
stack: error.stack,
|
|
1748
|
-
fullStack: error.fullStack,
|
|
1749
|
-
getSourcemap
|
|
1750
|
-
});
|
|
1751
|
-
if (stackFrames[0]) {
|
|
1752
|
-
file = stackFrames[0].file || test.testPath;
|
|
1753
|
-
line = stackFrames[0].lineNumber || 1;
|
|
1754
|
-
column = stackFrames[0].column || 1;
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
logs.push(`::${type} file=${this.onWritePath?.(file) || file},line=${line},col=${column},title=${escapeData(title)}::${escapeData(message)}`);
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
this.log('::group::Error for GitHub Actions');
|
|
1761
|
-
for (const log of logs)this.log(log);
|
|
1762
|
-
this.log('::endgroup::');
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
function escapeData(s) {
|
|
1766
|
-
return s.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/:/g, '%3A').replace(/,/g, '%2C');
|
|
1767
|
-
}
|
|
1768
|
-
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1769
|
-
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
1770
|
-
const pattern = [
|
|
1771
|
-
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
1772
|
-
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
|
|
1773
|
-
].join('|');
|
|
1774
|
-
return new RegExp(pattern, onlyFirst ? void 0 : 'g');
|
|
1775
|
-
}
|
|
1776
|
-
const regex = ansiRegex();
|
|
1777
|
-
function stripAnsi(string) {
|
|
1778
|
-
if ('string' != typeof string) throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
1779
|
-
return string.replace(regex, '');
|
|
1780
|
-
}
|
|
1781
|
-
const schemeRegex = /^[\w+.-]+:\/\//;
|
|
1782
|
-
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
1783
|
-
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
1784
|
-
function isAbsoluteUrl(input) {
|
|
1785
|
-
return schemeRegex.test(input);
|
|
1786
|
-
}
|
|
1787
|
-
function isSchemeRelativeUrl(input) {
|
|
1788
|
-
return input.startsWith('//');
|
|
1789
|
-
}
|
|
1790
|
-
function isAbsolutePath(input) {
|
|
1791
|
-
return input.startsWith('/');
|
|
1792
|
-
}
|
|
1793
|
-
function isFileUrl(input) {
|
|
1794
|
-
return input.startsWith('file:');
|
|
1795
|
-
}
|
|
1796
|
-
function isRelative(input) {
|
|
1797
|
-
return /^[.?#]/.test(input);
|
|
1798
|
-
}
|
|
1799
|
-
function parseAbsoluteUrl(input) {
|
|
1800
|
-
const match = urlRegex.exec(input);
|
|
1801
|
-
return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || '');
|
|
1802
|
-
}
|
|
1803
|
-
function parseFileUrl(input) {
|
|
1804
|
-
const match = fileRegex.exec(input);
|
|
1805
|
-
const path = match[2];
|
|
1806
|
-
return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || '');
|
|
1807
|
-
}
|
|
1808
|
-
function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
1809
|
-
return {
|
|
1810
|
-
scheme,
|
|
1811
|
-
user,
|
|
1812
|
-
host,
|
|
1813
|
-
port,
|
|
1814
|
-
path,
|
|
1815
|
-
query,
|
|
1816
|
-
hash,
|
|
1817
|
-
type: 7
|
|
1818
|
-
};
|
|
1819
|
-
}
|
|
1820
|
-
function parseUrl(input) {
|
|
1821
|
-
if (isSchemeRelativeUrl(input)) {
|
|
1822
|
-
const url = parseAbsoluteUrl('http:' + input);
|
|
1823
|
-
url.scheme = '';
|
|
1824
|
-
url.type = 6;
|
|
1825
|
-
return url;
|
|
1826
|
-
}
|
|
1827
|
-
if (isAbsolutePath(input)) {
|
|
1828
|
-
const url = parseAbsoluteUrl('http://foo.com' + input);
|
|
1829
|
-
url.scheme = '';
|
|
1830
|
-
url.host = '';
|
|
1831
|
-
url.type = 5;
|
|
1832
|
-
return url;
|
|
1833
|
-
}
|
|
1834
|
-
if (isFileUrl(input)) return parseFileUrl(input);
|
|
1835
|
-
if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
|
|
1836
|
-
const url = parseAbsoluteUrl('http://foo.com/' + input);
|
|
1837
|
-
url.scheme = '';
|
|
1838
|
-
url.host = '';
|
|
1839
|
-
url.type = input ? input.startsWith('?') ? 3 : input.startsWith('#') ? 2 : 4 : 1;
|
|
1840
|
-
return url;
|
|
1841
|
-
}
|
|
1842
|
-
function stripPathFilename(path) {
|
|
1843
|
-
if (path.endsWith('/..')) return path;
|
|
1844
|
-
const index = path.lastIndexOf('/');
|
|
1845
|
-
return path.slice(0, index + 1);
|
|
1846
|
-
}
|
|
1847
|
-
function mergePaths(url, base) {
|
|
1848
|
-
normalizePath(base, base.type);
|
|
1849
|
-
if ('/' === url.path) url.path = base.path;
|
|
1850
|
-
else url.path = stripPathFilename(base.path) + url.path;
|
|
1851
|
-
}
|
|
1852
|
-
function normalizePath(url, type) {
|
|
1853
|
-
const rel = type <= 4;
|
|
1854
|
-
const pieces = url.path.split('/');
|
|
1855
|
-
let pointer = 1;
|
|
1856
|
-
let positive = 0;
|
|
1857
|
-
let addTrailingSlash = false;
|
|
1858
|
-
for(let i = 1; i < pieces.length; i++){
|
|
1859
|
-
const piece = pieces[i];
|
|
1860
|
-
if (!piece) {
|
|
1861
|
-
addTrailingSlash = true;
|
|
1862
|
-
continue;
|
|
1863
|
-
}
|
|
1864
|
-
addTrailingSlash = false;
|
|
1865
|
-
if ('.' !== piece) {
|
|
1866
|
-
if ('..' === piece) {
|
|
1867
|
-
if (positive) {
|
|
1868
|
-
addTrailingSlash = true;
|
|
1869
|
-
positive--;
|
|
1870
|
-
pointer--;
|
|
1871
|
-
} else if (rel) pieces[pointer++] = piece;
|
|
1872
|
-
continue;
|
|
1873
|
-
}
|
|
1874
|
-
pieces[pointer++] = piece;
|
|
1875
|
-
positive++;
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
let path = '';
|
|
1879
|
-
for(let i = 1; i < pointer; i++)path += '/' + pieces[i];
|
|
1880
|
-
if (!path || addTrailingSlash && !path.endsWith('/..')) path += '/';
|
|
1881
|
-
url.path = path;
|
|
1882
|
-
}
|
|
1883
|
-
function resolve_uri_resolve(input, base) {
|
|
1884
|
-
if (!input && !base) return '';
|
|
1885
|
-
const url = parseUrl(input);
|
|
1886
|
-
let inputType = url.type;
|
|
1887
|
-
if (base && 7 !== inputType) {
|
|
1888
|
-
const baseUrl = parseUrl(base);
|
|
1889
|
-
const baseType = baseUrl.type;
|
|
1890
|
-
switch(inputType){
|
|
1891
|
-
case 1:
|
|
1892
|
-
url.hash = baseUrl.hash;
|
|
1893
|
-
case 2:
|
|
1894
|
-
url.query = baseUrl.query;
|
|
1895
|
-
case 3:
|
|
1896
|
-
case 4:
|
|
1897
|
-
mergePaths(url, baseUrl);
|
|
1898
|
-
case 5:
|
|
1899
|
-
url.user = baseUrl.user;
|
|
1900
|
-
url.host = baseUrl.host;
|
|
1901
|
-
url.port = baseUrl.port;
|
|
1902
|
-
case 6:
|
|
1903
|
-
url.scheme = baseUrl.scheme;
|
|
1904
|
-
}
|
|
1905
|
-
if (baseType > inputType) inputType = baseType;
|
|
1906
|
-
}
|
|
1907
|
-
normalizePath(url, inputType);
|
|
1908
|
-
const queryHash = url.query + url.hash;
|
|
1909
|
-
switch(inputType){
|
|
1910
|
-
case 2:
|
|
1911
|
-
case 3:
|
|
1912
|
-
return queryHash;
|
|
1913
|
-
case 4:
|
|
1914
|
-
{
|
|
1915
|
-
const path = url.path.slice(1);
|
|
1916
|
-
if (!path) return queryHash || '.';
|
|
1917
|
-
if (isRelative(base || input) && !isRelative(path)) return './' + path + queryHash;
|
|
1918
|
-
return path + queryHash;
|
|
1919
|
-
}
|
|
1920
|
-
case 5:
|
|
1921
|
-
return url.path + queryHash;
|
|
1922
|
-
default:
|
|
1923
|
-
return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
function stripFilename(path) {
|
|
1927
|
-
if (!path) return "";
|
|
1928
|
-
const index = path.lastIndexOf("/");
|
|
1929
|
-
return path.slice(0, index + 1);
|
|
1930
|
-
}
|
|
1931
|
-
function trace_mapping_resolver(mapUrl, sourceRoot) {
|
|
1932
|
-
const from = stripFilename(mapUrl);
|
|
1933
|
-
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
1934
|
-
return (source)=>resolve_uri_resolve(prefix + (source || ""), from);
|
|
1935
|
-
}
|
|
1936
|
-
var COLUMN = 0;
|
|
1937
|
-
var SOURCES_INDEX = 1;
|
|
1938
|
-
var SOURCE_LINE = 2;
|
|
1939
|
-
var SOURCE_COLUMN = 3;
|
|
1940
|
-
var NAMES_INDEX = 4;
|
|
1941
|
-
function maybeSort(mappings, owned) {
|
|
1942
|
-
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
1943
|
-
if (unsortedIndex === mappings.length) return mappings;
|
|
1944
|
-
if (!owned) mappings = mappings.slice();
|
|
1945
|
-
for(let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1))mappings[i] = sortSegments(mappings[i], owned);
|
|
1946
|
-
return mappings;
|
|
1947
|
-
}
|
|
1948
|
-
function nextUnsortedSegmentLine(mappings, start) {
|
|
1949
|
-
for(let i = start; i < mappings.length; i++)if (!isSorted(mappings[i])) return i;
|
|
1950
|
-
return mappings.length;
|
|
1951
|
-
}
|
|
1952
|
-
function isSorted(line) {
|
|
1953
|
-
for(let j = 1; j < line.length; j++)if (line[j][COLUMN] < line[j - 1][COLUMN]) return false;
|
|
1954
|
-
return true;
|
|
1955
|
-
}
|
|
1956
|
-
function sortSegments(line, owned) {
|
|
1957
|
-
if (!owned) line = line.slice();
|
|
1958
|
-
return line.sort(sortComparator);
|
|
1959
|
-
}
|
|
1960
|
-
function sortComparator(a, b) {
|
|
1961
|
-
return a[COLUMN] - b[COLUMN];
|
|
1962
|
-
}
|
|
1963
|
-
var found = false;
|
|
1964
|
-
function binarySearch(haystack, needle, low, high) {
|
|
1965
|
-
while(low <= high){
|
|
1966
|
-
const mid = low + (high - low >> 1);
|
|
1967
|
-
const cmp = haystack[mid][COLUMN] - needle;
|
|
1968
|
-
if (0 === cmp) {
|
|
1969
|
-
found = true;
|
|
1970
|
-
return mid;
|
|
1971
|
-
}
|
|
1972
|
-
if (cmp < 0) low = mid + 1;
|
|
1973
|
-
else high = mid - 1;
|
|
1974
|
-
}
|
|
1975
|
-
found = false;
|
|
1976
|
-
return low - 1;
|
|
1977
|
-
}
|
|
1978
|
-
function upperBound(haystack, needle, index) {
|
|
1979
|
-
for(let i = index + 1; i < haystack.length && haystack[i][COLUMN] === needle; index = i++);
|
|
1980
|
-
return index;
|
|
1981
|
-
}
|
|
1982
|
-
function lowerBound(haystack, needle, index) {
|
|
1983
|
-
for(let i = index - 1; i >= 0 && haystack[i][COLUMN] === needle; index = i--);
|
|
1984
|
-
return index;
|
|
1985
|
-
}
|
|
1986
|
-
function memoizedState() {
|
|
1987
|
-
return {
|
|
1988
|
-
lastKey: -1,
|
|
1989
|
-
lastNeedle: -1,
|
|
1990
|
-
lastIndex: -1
|
|
1991
|
-
};
|
|
1992
|
-
}
|
|
1993
|
-
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
1994
|
-
const { lastKey, lastNeedle, lastIndex } = state;
|
|
1995
|
-
let low = 0;
|
|
1996
|
-
let high = haystack.length - 1;
|
|
1997
|
-
if (key === lastKey) {
|
|
1998
|
-
if (needle === lastNeedle) {
|
|
1999
|
-
found = -1 !== lastIndex && haystack[lastIndex][COLUMN] === needle;
|
|
2000
|
-
return lastIndex;
|
|
2001
|
-
}
|
|
2002
|
-
if (needle >= lastNeedle) low = -1 === lastIndex ? 0 : lastIndex;
|
|
2003
|
-
else high = lastIndex;
|
|
2004
|
-
}
|
|
2005
|
-
state.lastKey = key;
|
|
2006
|
-
state.lastNeedle = needle;
|
|
2007
|
-
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
2008
|
-
}
|
|
2009
|
-
function trace_mapping_parse(map) {
|
|
2010
|
-
return "string" == typeof map ? JSON.parse(map) : map;
|
|
2011
|
-
}
|
|
2012
|
-
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
2013
|
-
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
2014
|
-
var LEAST_UPPER_BOUND = -1;
|
|
2015
|
-
var GREATEST_LOWER_BOUND = 1;
|
|
2016
|
-
var TraceMap = class {
|
|
2017
|
-
constructor(map, mapUrl){
|
|
2018
|
-
const isString = "string" == typeof map;
|
|
2019
|
-
if (!isString && map._decodedMemo) return map;
|
|
2020
|
-
const parsed = trace_mapping_parse(map);
|
|
2021
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
2022
|
-
this.version = version;
|
|
2023
|
-
this.file = file;
|
|
2024
|
-
this.names = names || [];
|
|
2025
|
-
this.sourceRoot = sourceRoot;
|
|
2026
|
-
this.sources = sources;
|
|
2027
|
-
this.sourcesContent = sourcesContent;
|
|
2028
|
-
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
2029
|
-
const resolve = trace_mapping_resolver(mapUrl, sourceRoot);
|
|
2030
|
-
this.resolvedSources = sources.map(resolve);
|
|
2031
|
-
const { mappings } = parsed;
|
|
2032
|
-
if ("string" == typeof mappings) {
|
|
2033
|
-
this._encoded = mappings;
|
|
2034
|
-
this._decoded = void 0;
|
|
2035
|
-
} else if (Array.isArray(mappings)) {
|
|
2036
|
-
this._encoded = void 0;
|
|
2037
|
-
this._decoded = maybeSort(mappings, isString);
|
|
2038
|
-
} else if (parsed.sections) throw new Error("TraceMap passed sectioned source map, please use FlattenMap export instead");
|
|
2039
|
-
else throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
2040
|
-
this._decodedMemo = memoizedState();
|
|
2041
|
-
this._bySources = void 0;
|
|
2042
|
-
this._bySourceMemos = void 0;
|
|
2043
|
-
}
|
|
2044
|
-
};
|
|
2045
|
-
function cast(map) {
|
|
2046
|
-
return map;
|
|
2047
|
-
}
|
|
2048
|
-
function decodedMappings(map) {
|
|
2049
|
-
var _a;
|
|
2050
|
-
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
2051
|
-
}
|
|
2052
|
-
function originalPositionFor(map, needle) {
|
|
2053
|
-
let { line, column, bias } = needle;
|
|
2054
|
-
line--;
|
|
2055
|
-
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
2056
|
-
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
2057
|
-
const decoded = decodedMappings(map);
|
|
2058
|
-
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
2059
|
-
const segments = decoded[line];
|
|
2060
|
-
const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
|
2061
|
-
if (-1 === index) return OMapping(null, null, null, null);
|
|
2062
|
-
const segment = segments[index];
|
|
2063
|
-
if (1 === segment.length) return OMapping(null, null, null, null);
|
|
2064
|
-
const { names, resolvedSources } = map;
|
|
2065
|
-
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], 5 === segment.length ? names[segment[NAMES_INDEX]] : null);
|
|
2066
|
-
}
|
|
2067
|
-
function OMapping(source, line, column, name) {
|
|
2068
|
-
return {
|
|
2069
|
-
source,
|
|
2070
|
-
line,
|
|
2071
|
-
column,
|
|
2072
|
-
name
|
|
2073
|
-
};
|
|
2074
|
-
}
|
|
2075
|
-
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
2076
|
-
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
2077
|
-
if (found) index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
2078
|
-
else if (bias === LEAST_UPPER_BOUND) index++;
|
|
2079
|
-
if (-1 === index || index === segments.length) return -1;
|
|
2080
|
-
return index;
|
|
2081
|
-
}
|
|
2082
|
-
const hintNotDefinedError = (message)=>{
|
|
2083
|
-
const [, varName] = message.match(/(\w+) is not defined/) || [];
|
|
2084
|
-
if (varName) {
|
|
2085
|
-
if (globalApis.includes(varName)) return message.replace(`${varName} is not defined`, `${varName} is not defined. Did you forget to enable "globals" configuration?`);
|
|
2086
|
-
if ([
|
|
2087
|
-
'jest',
|
|
2088
|
-
'vitest'
|
|
2089
|
-
].includes(varName)) return message.replace(`${varName} is not defined`, `${varName} is not defined. Did you mean rstest?`);
|
|
2090
|
-
if ('React' === varName) return message.replace(`${varName} is not defined`, `${varName} is not defined. Did you forget to install "${picocolors_default().yellow('@rsbuild/plugin-react')}" plugin?`);
|
|
2091
|
-
}
|
|
2092
|
-
return message;
|
|
2093
|
-
};
|
|
2094
|
-
async function error_printError(error, getSourcemap, rootPath) {
|
|
2095
|
-
const errorName = error.name || 'Unknown Error';
|
|
2096
|
-
if (error.message.includes('Vitest failed to access its internal state')) {
|
|
2097
|
-
const tips = [
|
|
2098
|
-
'Error: not support import `vitest` in Rstest test environment.\n',
|
|
2099
|
-
'Solution:',
|
|
2100
|
-
` - Update your code to use imports from "${picocolors_default().yellow('@rstest/core')}" instead of "${picocolors_default().yellow('vitest')}".`,
|
|
2101
|
-
' - Enable `globals` configuration and use global API.'
|
|
2102
|
-
];
|
|
2103
|
-
src_logger.log(`${picocolors_default().red(tips.join('\n'))}\n`);
|
|
2104
|
-
return;
|
|
2105
|
-
}
|
|
2106
|
-
if (error.message.includes('is not defined')) error.message = hintNotDefinedError(error.message);
|
|
2107
|
-
src_logger.log(`${picocolors_default().red(picocolors_default().bold(errorName))}${picocolors_default().red(`: ${error.message}`)}\n`);
|
|
2108
|
-
if (error.diff) {
|
|
2109
|
-
src_logger.log(error.diff);
|
|
2110
|
-
src_logger.log();
|
|
2111
|
-
}
|
|
2112
|
-
if (error.stack) {
|
|
2113
|
-
const stackFrames = await error_parseErrorStacktrace({
|
|
2114
|
-
stack: error.stack,
|
|
2115
|
-
fullStack: error.fullStack,
|
|
2116
|
-
getSourcemap
|
|
2117
|
-
});
|
|
2118
|
-
if (!stackFrames.length && error.stack.length) src_logger.log(picocolors_default().gray("No error stack found, set 'DEBUG=rstest' to show fullStack."));
|
|
2119
|
-
if (stackFrames[0]) await printCodeFrame(stackFrames[0]);
|
|
2120
|
-
printStack(stackFrames, rootPath);
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
async function printCodeFrame(frame) {
|
|
2124
|
-
const filePath = frame.file?.startsWith('file') ? new URL(frame.file) : frame.file;
|
|
2125
|
-
if (!filePath) return;
|
|
2126
|
-
const source = external_node_fs_["default"].existsSync(filePath) ? external_node_fs_["default"].readFileSync(filePath, 'utf-8') : void 0;
|
|
2127
|
-
if (!source) return;
|
|
2128
|
-
const { codeFrameColumns } = await import("./0~171.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/@babel+code-frame@7.27.1/node_modules/@babel/code-frame/lib/index.js"));
|
|
2129
|
-
const result = codeFrameColumns(source, {
|
|
2130
|
-
start: {
|
|
2131
|
-
line: frame.lineNumber,
|
|
2132
|
-
column: frame.column
|
|
2133
|
-
}
|
|
2134
|
-
}, {
|
|
2135
|
-
highlightCode: true,
|
|
2136
|
-
linesBelow: 2
|
|
2137
|
-
});
|
|
2138
|
-
src_logger.log(result);
|
|
2139
|
-
src_logger.log('');
|
|
2140
|
-
}
|
|
2141
|
-
function formatStack(frame, rootPath) {
|
|
2142
|
-
return '<unknown>' !== frame.methodName ? `at ${frame.methodName} (${formatTestPath(rootPath, frame.file)}:${frame.lineNumber}:${frame.column})` : `at ${formatTestPath(rootPath, frame.file)}:${frame.lineNumber}:${frame.column}`;
|
|
2143
|
-
}
|
|
2144
|
-
function printStack(stackFrames, rootPath) {
|
|
2145
|
-
for (const frame of stackFrames)src_logger.log(picocolors_default().gray(` ${formatStack(frame, rootPath)}`));
|
|
2146
|
-
stackFrames.length && src_logger.log();
|
|
2147
|
-
}
|
|
2148
|
-
const stackIgnores = [
|
|
2149
|
-
/\/@rstest\/core/,
|
|
2150
|
-
/rstest\/packages\/core\/dist/,
|
|
2151
|
-
/node_modules\/tinypool/,
|
|
2152
|
-
/node_modules\/chai/,
|
|
2153
|
-
/node_modules\/@vitest\/expect/,
|
|
2154
|
-
/node_modules\/@vitest\/snapshot/,
|
|
2155
|
-
/node:\w+/,
|
|
2156
|
-
/webpack\/runtime/,
|
|
2157
|
-
/webpack\\runtime/,
|
|
2158
|
-
'<anonymous>'
|
|
2159
|
-
];
|
|
2160
|
-
async function error_parseErrorStacktrace({ stack, getSourcemap, fullStack = isDebug() }) {
|
|
2161
|
-
const stackFrames = await Promise.all(stack_trace_parser_esm_parse(stack).filter((frame)=>fullStack ? true : frame.file && !stackIgnores.some((entry)=>frame.file?.match(entry))).map(async (frame)=>{
|
|
2162
|
-
const sourcemap = await getSourcemap(frame.file);
|
|
2163
|
-
if (sourcemap) {
|
|
2164
|
-
const traceMap = new TraceMap(sourcemap);
|
|
2165
|
-
const { line, column, source, name } = originalPositionFor(traceMap, {
|
|
2166
|
-
line: frame.lineNumber,
|
|
2167
|
-
column: frame.column
|
|
2168
|
-
});
|
|
2169
|
-
if (!source) return null;
|
|
2170
|
-
return {
|
|
2171
|
-
...frame,
|
|
2172
|
-
file: source,
|
|
2173
|
-
lineNumber: line,
|
|
2174
|
-
name,
|
|
2175
|
-
column
|
|
2176
|
-
};
|
|
2177
|
-
}
|
|
2178
|
-
return frame;
|
|
2179
|
-
})).then((frames)=>frames.filter((frame)=>null !== frame));
|
|
2180
|
-
return stackFrames;
|
|
2181
|
-
}
|
|
2182
|
-
class JUnitReporter {
|
|
2183
|
-
rootPath;
|
|
2184
|
-
outputPath;
|
|
2185
|
-
constructor({ rootPath, options: { outputPath } = {} }){
|
|
2186
|
-
this.rootPath = rootPath;
|
|
2187
|
-
this.outputPath = outputPath;
|
|
2188
|
-
}
|
|
2189
|
-
sanitizeXml(text) {
|
|
2190
|
-
let result = '';
|
|
2191
|
-
for (const ch of stripAnsi(text)){
|
|
2192
|
-
const cp = ch.codePointAt(0);
|
|
2193
|
-
const valid = 0x09 === cp || 0x0a === cp || 0x0d === cp || cp >= 0x20 && cp <= 0xd7ff || cp >= 0xe000 && cp <= 0xfffd || cp >= 0x10000 && cp <= 0x10ffff;
|
|
2194
|
-
if (valid) result += ch;
|
|
2195
|
-
}
|
|
2196
|
-
return result;
|
|
2197
|
-
}
|
|
2198
|
-
escapeXml(text) {
|
|
2199
|
-
const sanitized = this.sanitizeXml(text);
|
|
2200
|
-
return sanitized.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
2201
|
-
}
|
|
2202
|
-
async createJUnitTestCase(test, getSourcemap) {
|
|
2203
|
-
const testCase = {
|
|
2204
|
-
name: getTaskNameWithPrefix(test),
|
|
2205
|
-
classname: pathe_M_eThtNZ_relative(this.rootPath, test.testPath),
|
|
2206
|
-
time: (test.duration || 0) / 1000,
|
|
2207
|
-
status: test.status
|
|
2208
|
-
};
|
|
2209
|
-
if (test.errors && test.errors.length > 0) testCase.errors = await Promise.all(test.errors.map(async (error)=>{
|
|
2210
|
-
let details = `${error.message}${error.diff ? `\n${error.diff}` : ''}`;
|
|
2211
|
-
const stackFrames = error.stack ? await error_parseErrorStacktrace({
|
|
2212
|
-
stack: error.stack,
|
|
2213
|
-
fullStack: error.fullStack,
|
|
2214
|
-
getSourcemap
|
|
2215
|
-
}) : [];
|
|
2216
|
-
if (stackFrames[0]) details += `\n${formatStack(stackFrames[0], this.rootPath)}`;
|
|
2217
|
-
return {
|
|
2218
|
-
message: this.escapeXml(error.message),
|
|
2219
|
-
type: error.name || 'Error',
|
|
2220
|
-
details: this.escapeXml(details)
|
|
2221
|
-
};
|
|
2222
|
-
}));
|
|
2223
|
-
return testCase;
|
|
2224
|
-
}
|
|
2225
|
-
async createJUnitTestSuite(fileResult, getSourcemap) {
|
|
2226
|
-
const testCases = await Promise.all(fileResult.results.map(async (test)=>this.createJUnitTestCase(test, getSourcemap)));
|
|
2227
|
-
const failures = testCases.filter((test)=>'fail' === test.status).length;
|
|
2228
|
-
const errors = 0;
|
|
2229
|
-
const skipped = testCases.filter((test)=>'skip' === test.status || 'todo' === test.status).length;
|
|
2230
|
-
const totalTime = testCases.reduce((sum, test)=>sum + test.time, 0);
|
|
2231
|
-
return {
|
|
2232
|
-
name: pathe_M_eThtNZ_relative(this.rootPath, fileResult.testPath),
|
|
2233
|
-
tests: testCases.length,
|
|
2234
|
-
failures,
|
|
2235
|
-
errors,
|
|
2236
|
-
skipped,
|
|
2237
|
-
time: totalTime,
|
|
2238
|
-
timestamp: new Date().toISOString(),
|
|
2239
|
-
testcases: testCases
|
|
2240
|
-
};
|
|
2241
|
-
}
|
|
2242
|
-
generateJUnitXml(report) {
|
|
2243
|
-
const xmlDeclaration = '<?xml version="1.0" encoding="UTF-8"?>';
|
|
2244
|
-
const testsuitesXml = `
|
|
2245
|
-
<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)}">`;
|
|
2246
|
-
const testsuiteXmls = report.testsuites.testsuite.map((suite)=>{
|
|
2247
|
-
const testsuiteStart = `
|
|
2248
|
-
<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)}">`;
|
|
2249
|
-
const testcaseXmls = suite.testcases.map((testcase)=>{
|
|
2250
|
-
let testcaseXml = `
|
|
2251
|
-
<testcase name="${this.escapeXml(testcase.name)}" classname="${this.escapeXml(testcase.classname)}" time="${testcase.time}">`;
|
|
2252
|
-
if ('skip' === testcase.status || 'todo' === testcase.status) testcaseXml += `
|
|
2253
|
-
<skipped/>`;
|
|
2254
|
-
else if ('fail' === testcase.status && testcase.errors) testcase.errors.forEach((error)=>{
|
|
2255
|
-
testcaseXml += `
|
|
2256
|
-
<failure message="${error.message}" type="${error.type}">${error.details || ''}</failure>`;
|
|
2257
|
-
});
|
|
2258
|
-
testcaseXml += `
|
|
2259
|
-
</testcase>`;
|
|
2260
|
-
return testcaseXml;
|
|
2261
|
-
}).join('');
|
|
2262
|
-
const testsuiteEnd = `
|
|
2263
|
-
</testsuite>`;
|
|
2264
|
-
return testsuiteStart + testcaseXmls + testsuiteEnd;
|
|
2265
|
-
}).join('');
|
|
2266
|
-
const testsuitesEnd = `
|
|
2267
|
-
</testsuites>`;
|
|
2268
|
-
return xmlDeclaration + testsuitesXml + testsuiteXmls + testsuitesEnd;
|
|
2269
|
-
}
|
|
2270
|
-
async onTestRunEnd({ results, testResults, duration, getSourcemap }) {
|
|
2271
|
-
const testSuites = await Promise.all(results.map(async (fileResult)=>this.createJUnitTestSuite(fileResult, getSourcemap)));
|
|
2272
|
-
const totalTests = testResults.length;
|
|
2273
|
-
const totalFailures = testResults.filter((test)=>'fail' === test.status).length;
|
|
2274
|
-
const totalErrors = 0;
|
|
2275
|
-
const totalSkipped = testResults.filter((test)=>'skip' === test.status || 'todo' === test.status).length;
|
|
2276
|
-
const totalTime = duration.testTime / 1000;
|
|
2277
|
-
const report = {
|
|
2278
|
-
testsuites: {
|
|
2279
|
-
name: 'rstest tests',
|
|
2280
|
-
tests: totalTests,
|
|
2281
|
-
failures: totalFailures,
|
|
2282
|
-
errors: totalErrors,
|
|
2283
|
-
skipped: totalSkipped,
|
|
2284
|
-
time: totalTime,
|
|
2285
|
-
timestamp: new Date().toISOString(),
|
|
2286
|
-
testsuite: testSuites
|
|
2287
|
-
}
|
|
2288
|
-
};
|
|
2289
|
-
const xmlContent = this.generateJUnitXml(report);
|
|
2290
|
-
if (this.outputPath) try {
|
|
2291
|
-
await writeFile(this.outputPath, xmlContent, 'utf-8');
|
|
2292
|
-
console.log(`JUnit XML report written to: ${this.outputPath}`);
|
|
2293
|
-
} catch (error) {
|
|
2294
|
-
console.error(`Failed to write JUnit XML report to ${this.outputPath}:`, error);
|
|
2295
|
-
console.log('JUnit XML Report:');
|
|
2296
|
-
console.log(xmlContent);
|
|
2297
|
-
}
|
|
2298
|
-
else console.log(xmlContent);
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
class VerboseReporter extends DefaultReporter {
|
|
2302
|
-
onTestFileResult(test) {
|
|
2303
|
-
this.statusRenderer?.onTestFileResult(test);
|
|
2304
|
-
const relativePath = pathe_M_eThtNZ_relative(this.rootPath, test.testPath);
|
|
2305
|
-
const { slowTestThreshold } = this.config;
|
|
2306
|
-
logFileTitle(test, relativePath, true);
|
|
2307
|
-
for (const result of test.results)logCase(result, {
|
|
2308
|
-
slowTestThreshold,
|
|
2309
|
-
hideSkippedTests: this.config.hideSkippedTests
|
|
2310
|
-
});
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
class TestStateManager {
|
|
2314
|
-
runningModules = new Map();
|
|
2315
|
-
testModules = [];
|
|
2316
|
-
onTestFileStart(testPath) {
|
|
2317
|
-
this.runningModules.set(testPath, []);
|
|
2318
|
-
}
|
|
2319
|
-
onTestCaseResult(result) {
|
|
2320
|
-
this.runningModules.set(result.testPath, [
|
|
2321
|
-
...this.runningModules.get(result.testPath) || [],
|
|
2322
|
-
result
|
|
2323
|
-
]);
|
|
2324
|
-
}
|
|
2325
|
-
getCountOfFailedTests() {
|
|
2326
|
-
const testResults = Array.from(this.runningModules.values()).flat().concat(this.testModules.flatMap((mod)=>mod.results));
|
|
2327
|
-
return testResults.filter((t)=>'fail' === t.status).length;
|
|
2328
|
-
}
|
|
2329
|
-
onTestFileResult(test) {
|
|
2330
|
-
this.runningModules.delete(test.testPath);
|
|
2331
|
-
this.testModules.push(test);
|
|
2332
|
-
}
|
|
2333
|
-
reset() {
|
|
2334
|
-
this.runningModules.clear();
|
|
2335
|
-
this.testModules = [];
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
function formatEnvironmentName(name) {
|
|
2339
|
-
return name.replace(/[^a-zA-Z0-9\-_$]/g, '_');
|
|
2340
|
-
}
|
|
2341
|
-
class Rstest {
|
|
2342
|
-
cwd;
|
|
2343
|
-
command;
|
|
2344
|
-
fileFilters;
|
|
2345
|
-
configFilePath;
|
|
2346
|
-
reporters;
|
|
2347
|
-
snapshotManager;
|
|
2348
|
-
version;
|
|
2349
|
-
rootPath;
|
|
2350
|
-
originalConfig;
|
|
2351
|
-
normalizedConfig;
|
|
2352
|
-
reporterResults = {
|
|
2353
|
-
results: [],
|
|
2354
|
-
testResults: []
|
|
2355
|
-
};
|
|
2356
|
-
stateManager = new TestStateManager();
|
|
2357
|
-
projects = [];
|
|
2358
|
-
constructor({ cwd = process.cwd(), command, fileFilters, configFilePath, projects }, userConfig){
|
|
2359
|
-
this.cwd = cwd;
|
|
2360
|
-
this.command = command;
|
|
2361
|
-
this.fileFilters = fileFilters;
|
|
2362
|
-
this.configFilePath = configFilePath;
|
|
2363
|
-
const rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd;
|
|
2364
|
-
const rstestConfig = withDefaultConfig({
|
|
2365
|
-
...userConfig,
|
|
2366
|
-
root: rootPath
|
|
2367
|
-
});
|
|
2368
|
-
const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
|
|
2369
|
-
rootPath,
|
|
2370
|
-
config: rstestConfig
|
|
2371
|
-
}) : [];
|
|
2372
|
-
const snapshotManager = new SnapshotManager({
|
|
2373
|
-
updateSnapshot: rstestConfig.update ? 'all' : T ? 'none' : 'new'
|
|
2374
|
-
});
|
|
2375
|
-
this.reporters = reporters;
|
|
2376
|
-
this.snapshotManager = snapshotManager;
|
|
2377
|
-
this.version = "0.6.5";
|
|
2378
|
-
this.rootPath = rootPath;
|
|
2379
|
-
this.originalConfig = userConfig;
|
|
2380
|
-
this.normalizedConfig = rstestConfig;
|
|
2381
|
-
this.projects = projects.length ? projects.map((project)=>{
|
|
2382
|
-
project.config.root = getAbsolutePath(rootPath, project.config.root);
|
|
2383
|
-
const config = withDefaultConfig(project.config);
|
|
2384
|
-
config.isolate = rstestConfig.isolate;
|
|
2385
|
-
config.coverage = rstestConfig.coverage;
|
|
2386
|
-
config.bail = rstestConfig.bail;
|
|
2387
|
-
config.source ??= {};
|
|
2388
|
-
if (config.source.tsconfigPath) config.source.tsconfigPath = getAbsolutePath(config.root, config.source.tsconfigPath);
|
|
2389
|
-
else {
|
|
2390
|
-
const tsconfigPath = join(config.root, TS_CONFIG_FILE);
|
|
2391
|
-
if ((0, external_node_fs_.existsSync)(tsconfigPath)) config.source.tsconfigPath = tsconfigPath;
|
|
2392
|
-
}
|
|
2393
|
-
return {
|
|
2394
|
-
configFilePath: project.configFilePath,
|
|
2395
|
-
rootPath: config.root,
|
|
2396
|
-
name: config.name,
|
|
2397
|
-
environmentName: formatEnvironmentName(config.name),
|
|
2398
|
-
normalizedConfig: config
|
|
2399
|
-
};
|
|
2400
|
-
}) : [
|
|
2401
|
-
{
|
|
2402
|
-
configFilePath,
|
|
2403
|
-
rootPath,
|
|
2404
|
-
name: rstestConfig.name,
|
|
2405
|
-
environmentName: formatEnvironmentName(rstestConfig.name),
|
|
2406
|
-
normalizedConfig: rstestConfig
|
|
2407
|
-
}
|
|
2408
|
-
];
|
|
2409
|
-
}
|
|
2410
|
-
updateReporterResultState(results, testResults, deletedEntries = []) {
|
|
2411
|
-
results.forEach((item)=>{
|
|
2412
|
-
const existingIndex = this.reporterResults.results.findIndex((r)=>r.testPath === item.testPath);
|
|
2413
|
-
if (-1 !== existingIndex) this.reporterResults.results[existingIndex] = item;
|
|
2414
|
-
else this.reporterResults.results.push(item);
|
|
2415
|
-
});
|
|
2416
|
-
const testPathsToUpdate = new Set(testResults.map((r)=>r.testPath));
|
|
2417
|
-
this.reporterResults.testResults = this.reporterResults.testResults.filter((r)=>!testPathsToUpdate.has(r.testPath));
|
|
2418
|
-
this.reporterResults.testResults.push(...testResults);
|
|
2419
|
-
if (deletedEntries.length > 0) {
|
|
2420
|
-
const deletedPathsSet = new Set(deletedEntries);
|
|
2421
|
-
this.reporterResults.results = this.reporterResults.results.filter((r)=>!deletedPathsSet.has(r.testPath));
|
|
2422
|
-
this.reporterResults.testResults = this.reporterResults.testResults.filter((r)=>!deletedPathsSet.has(r.testPath));
|
|
2423
|
-
}
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
const reportersMap = {
|
|
2427
|
-
default: DefaultReporter,
|
|
2428
|
-
verbose: VerboseReporter,
|
|
2429
|
-
'github-actions': GithubActionsReporter,
|
|
2430
|
-
junit: JUnitReporter
|
|
2431
|
-
};
|
|
2432
|
-
function createReporters(reporters, initOptions = {}) {
|
|
2433
|
-
const result = castArray(reporters).map((reporter)=>{
|
|
2434
|
-
if ('string' == typeof reporter || Array.isArray(reporter)) {
|
|
2435
|
-
const [name, options = {}] = 'string' == typeof reporter ? [
|
|
2436
|
-
reporter,
|
|
2437
|
-
{}
|
|
2438
|
-
] : reporter;
|
|
2439
|
-
if (name in reportersMap) {
|
|
2440
|
-
const Reporter = reportersMap[name];
|
|
2441
|
-
return new Reporter({
|
|
2442
|
-
...initOptions,
|
|
2443
|
-
options
|
|
2444
|
-
});
|
|
2445
|
-
}
|
|
2446
|
-
throw new Error(`Reporter ${reporter} not found. Please install it or use a built-in reporter.`);
|
|
2447
|
-
}
|
|
2448
|
-
return reporter;
|
|
2449
|
-
});
|
|
2450
|
-
return result;
|
|
2451
|
-
}
|
|
2452
|
-
function core_createRstest({ config, projects, configFilePath }, command, fileFilters) {
|
|
2453
|
-
const context = new Rstest({
|
|
2454
|
-
cwd: process.cwd(),
|
|
2455
|
-
command,
|
|
2456
|
-
fileFilters,
|
|
2457
|
-
configFilePath,
|
|
2458
|
-
projects
|
|
2459
|
-
}, config);
|
|
2460
|
-
const runTests = async ()=>{
|
|
2461
|
-
const { runTests } = await import("./0~470.js").then((mod)=>({
|
|
2462
|
-
runTests: mod.runTests
|
|
2463
|
-
}));
|
|
2464
|
-
await runTests(context);
|
|
2465
|
-
};
|
|
2466
|
-
const listTests = async (options)=>{
|
|
2467
|
-
const { listTests } = await import("./0~971.js").then((mod)=>({
|
|
2468
|
-
listTests: mod.listTests
|
|
2469
|
-
}));
|
|
2470
|
-
await listTests(context, options);
|
|
2471
|
-
};
|
|
2472
|
-
return {
|
|
2473
|
-
context,
|
|
2474
|
-
runTests,
|
|
2475
|
-
listTests
|
|
2476
|
-
};
|
|
2477
|
-
}
|
|
2478
|
-
const check = (name)=>{
|
|
2479
|
-
if (!globalThis.RSTEST_API?.[name]) throw new Error(`Rstest API '${name}' is not registered yet, please make sure you are running in a rstest environment.`);
|
|
2480
|
-
};
|
|
2481
|
-
const wrapRstestAPI = (name)=>{
|
|
2482
|
-
const fn = (...args)=>{
|
|
2483
|
-
check(name);
|
|
2484
|
-
return globalThis.RSTEST_API[name].call(globalThis.RSTEST_API[name], ...args);
|
|
2485
|
-
};
|
|
2486
|
-
return new Proxy(fn, {
|
|
2487
|
-
get (_target, key, receiver) {
|
|
2488
|
-
check(name);
|
|
2489
|
-
return Reflect.get(globalThis.RSTEST_API?.[name] || {}, key, receiver);
|
|
2490
|
-
}
|
|
2491
|
-
});
|
|
2492
|
-
};
|
|
2493
|
-
const wrapRstestUtilitiesAPI = (name)=>new Proxy({}, {
|
|
2494
|
-
get (_target, key, receiver) {
|
|
2495
|
-
check(name);
|
|
2496
|
-
return Reflect.get(globalThis.RSTEST_API?.[name] || {}, key, receiver);
|
|
2497
|
-
}
|
|
2498
|
-
});
|
|
2499
|
-
const expect = wrapRstestAPI('expect');
|
|
2500
|
-
const assert = wrapRstestAPI('assert');
|
|
2501
|
-
const it = wrapRstestAPI('it');
|
|
2502
|
-
const public_test = wrapRstestAPI('test');
|
|
2503
|
-
const describe = wrapRstestAPI('describe');
|
|
2504
|
-
const beforeAll = wrapRstestAPI('beforeAll');
|
|
2505
|
-
const afterAll = wrapRstestAPI('afterAll');
|
|
2506
|
-
const beforeEach = wrapRstestAPI('beforeEach');
|
|
2507
|
-
const afterEach = wrapRstestAPI('afterEach');
|
|
2508
|
-
const public_rstest = wrapRstestUtilitiesAPI('rstest');
|
|
2509
|
-
const rs = wrapRstestUtilitiesAPI('rs');
|
|
2510
|
-
const onTestFinished = wrapRstestAPI('onTestFinished');
|
|
2511
|
-
const onTestFailed = wrapRstestAPI('onTestFailed');
|
|
2512
|
-
function defineConfig(config) {
|
|
2513
|
-
return config;
|
|
2514
|
-
}
|
|
2515
|
-
function defineProject(config) {
|
|
2516
|
-
return config;
|
|
2517
|
-
}
|
|
2518
|
-
export { EventEmitter, afterAll, afterEach, assert, beforeAll, beforeEach, config_loadConfig as loadConfig, core_createRstest as createRstest, createRsbuild, defineConfig, defineProject, describe, error_printError, expect, init_initCli as initCli, it, logger, mergeRstestConfig, onTestFailed, onTestFinished, public_rstest as rstest, public_test as test, rs, runCLI, runRest };
|
|
3
|
+
export { afterAll, afterEach, assert, beforeAll, beforeEach, createRstest, defineConfig, defineProject, describe, expect, initCli, it, loadConfig, mergeRstestConfig, onTestFailed, onTestFinished, rs, rstest, runCLI, test } from "./155.js";
|