@rstest/core 0.0.10 → 0.1.0
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/285.js +1 -1
- package/dist/355.js +4 -1
- package/dist/562.js +1 -1
- package/dist/629.js +1 -0
- package/dist/64.js +1 -1
- package/dist/813.js +1 -1
- package/dist/867.js +1 -1
- package/dist/{353.js → 950.js} +85 -16
- package/dist/cli.js +15 -11
- package/dist/worker.js +9 -6
- package/dist-types/node.d.ts +38 -3
- package/dist-types/public.d.ts +38 -3
- package/dist-types/worker.d.ts +38 -3
- package/package.json +3 -3
package/dist/285.js
CHANGED
|
@@ -6,7 +6,7 @@ export const __webpack_modules__ = {
|
|
|
6
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
7
7
|
listTests: ()=>listTests
|
|
8
8
|
});
|
|
9
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
9
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
10
10
|
var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
|
|
11
11
|
var _pool__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/pool/index.ts");
|
|
12
12
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
package/dist/355.js
CHANGED
|
@@ -4,9 +4,10 @@ export const __webpack_ids__ = [
|
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"./src/utils/error.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
7
|
+
parseErrorStacktrace: ()=>parseErrorStacktrace,
|
|
7
8
|
printError: ()=>printError
|
|
8
9
|
});
|
|
9
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
10
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
10
11
|
var _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.29/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs");
|
|
11
12
|
var stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
|
|
12
13
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
@@ -70,6 +71,8 @@ export const __webpack_modules__ = {
|
|
|
70
71
|
/node_modules\/@vitest\/expect/,
|
|
71
72
|
/node_modules\/@vitest\/snapshot/,
|
|
72
73
|
/node:\w+/,
|
|
74
|
+
/webpack\/runtime/,
|
|
75
|
+
/webpack\\runtime/,
|
|
73
76
|
'<anonymous>'
|
|
74
77
|
];
|
|
75
78
|
async function parseErrorStacktrace({ stack, getSourcemap, fullStack }) {
|
package/dist/562.js
CHANGED
|
@@ -7,7 +7,7 @@ export const __webpack_modules__ = {
|
|
|
7
7
|
r: ()=>createRsbuildServer,
|
|
8
8
|
z: ()=>prepareRsbuild
|
|
9
9
|
});
|
|
10
|
-
var external_node_fs_ = __webpack_require__("fs");
|
|
10
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
11
11
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
12
12
|
var external_pathe_ = __webpack_require__("pathe");
|
|
13
13
|
var utils = __webpack_require__("./src/utils/index.ts");
|
package/dist/629.js
CHANGED
|
@@ -71,6 +71,7 @@ export const __webpack_modules__ = {
|
|
|
71
71
|
};
|
|
72
72
|
if ('watch' === command) rsbuildInstance.onDevCompileDone(async ()=>{
|
|
73
73
|
await run();
|
|
74
|
+
_utils__WEBPACK_IMPORTED_MODULE_1__.kg.log(_utils__WEBPACK_IMPORTED_MODULE_1__.$_.green(' Waiting for file changes...'));
|
|
74
75
|
});
|
|
75
76
|
else {
|
|
76
77
|
const close = await run();
|
package/dist/64.js
CHANGED
|
@@ -38,7 +38,7 @@ export const __webpack_modules__ = {
|
|
|
38
38
|
var path = __webpack_require__("node:path");
|
|
39
39
|
var fs;
|
|
40
40
|
try {
|
|
41
|
-
fs = __webpack_require__("fs");
|
|
41
|
+
fs = __webpack_require__("node:fs");
|
|
42
42
|
if (!fs.existsSync || !fs.readFileSync) fs = null;
|
|
43
43
|
} catch (err) {}
|
|
44
44
|
var bufferFrom = __webpack_require__("../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js");
|
package/dist/813.js
CHANGED
|
@@ -132,7 +132,7 @@ export const __webpack_modules__ = {
|
|
|
132
132
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
133
133
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
134
134
|
__webpack_require__("./src/utils/logger.ts");
|
|
135
|
-
__webpack_require__("fs");
|
|
135
|
+
__webpack_require__("node:fs");
|
|
136
136
|
__webpack_require__("node:fs/promises");
|
|
137
137
|
__webpack_require__("node:module");
|
|
138
138
|
__webpack_require__("pathe");
|
package/dist/867.js
CHANGED
|
@@ -1743,7 +1743,7 @@ export const __webpack_modules__ = {
|
|
|
1743
1743
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
1744
1744
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
1745
1745
|
__webpack_require__("./src/utils/logger.ts");
|
|
1746
|
-
__webpack_require__("fs");
|
|
1746
|
+
__webpack_require__("node:fs");
|
|
1747
1747
|
__webpack_require__("node:fs/promises");
|
|
1748
1748
|
__webpack_require__("node:module");
|
|
1749
1749
|
__webpack_require__("pathe");
|
package/dist/{353.js → 950.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
"
|
|
2
|
+
"950"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -342,6 +342,23 @@ export const __webpack_modules__ = {
|
|
|
342
342
|
todo: utils.$_.gray(statusStr.todo),
|
|
343
343
|
skip: utils.$_.gray(statusStr.skip)
|
|
344
344
|
};
|
|
345
|
+
const logCase = (result, slowTestThreshold)=>{
|
|
346
|
+
const isSlowCase = (result.duration || 0) > slowTestThreshold;
|
|
347
|
+
const icon = isSlowCase && 'pass' === result.status ? utils.$_.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
|
|
348
|
+
const nameStr = (0, utils.Yz)(result);
|
|
349
|
+
const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration)})` : '';
|
|
350
|
+
const retry = result.retryCount ? utils.$_.yellow(` (retry x${result.retryCount})`) : '';
|
|
351
|
+
utils.kg.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}${retry}`);
|
|
352
|
+
if (result.errors) for (const error of result.errors)console.error(utils.$_.red(` ${error.message}`));
|
|
353
|
+
};
|
|
354
|
+
const logFileTitle = (test, relativePath, slowTestThreshold, alwaysShowTime = false)=>{
|
|
355
|
+
let title = ` ${utils.$_.bold(statusColorfulStr[test.status])} ${(0, utils.aj)(relativePath)}`;
|
|
356
|
+
const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](`${(0, utils.AS)(duration)}`);
|
|
357
|
+
title += ` ${utils.$_.gray(`(${test.results.length})`)}`;
|
|
358
|
+
const isTooSlow = test.duration && test.duration > slowTestThreshold;
|
|
359
|
+
if (alwaysShowTime || isTooSlow) title += ` ${formatDuration(test.duration)}`;
|
|
360
|
+
utils.kg.log(title);
|
|
361
|
+
};
|
|
345
362
|
class DefaultReporter {
|
|
346
363
|
rootPath;
|
|
347
364
|
config;
|
|
@@ -360,25 +377,15 @@ export const __webpack_modules__ = {
|
|
|
360
377
|
this.statusRenderer?.removeRunningModule(test.testPath);
|
|
361
378
|
const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
|
|
362
379
|
const { slowTestThreshold } = this.config;
|
|
363
|
-
|
|
364
|
-
const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](`${(0, utils.AS)(duration)}`);
|
|
365
|
-
title += ` ${utils.$_.gray(`(${test.results.length})`)}`;
|
|
380
|
+
logFileTitle(test, relativePath, slowTestThreshold);
|
|
366
381
|
const isTooSlow = test.duration && test.duration > slowTestThreshold;
|
|
367
|
-
if (isTooSlow) title += ` ${formatDuration(test.duration)}`;
|
|
368
382
|
const hasRetryCase = test.results.some((result)=>(result.retryCount || 0) > 0);
|
|
369
|
-
utils.kg.log(title);
|
|
370
383
|
if ('fail' !== test.status && !isTooSlow && !hasRetryCase) return;
|
|
371
384
|
const showAllCases = isTooSlow && !test.results.some((result)=>(result.duration || 0) > slowTestThreshold);
|
|
372
385
|
for (const result of test.results){
|
|
373
386
|
const isSlowCase = (result.duration || 0) > slowTestThreshold;
|
|
374
387
|
const retried = (result.retryCount || 0) > 0;
|
|
375
|
-
if (
|
|
376
|
-
const icon = isSlowCase && 'pass' === result.status ? utils.$_.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
|
|
377
|
-
const nameStr = (0, utils.Yz)(result);
|
|
378
|
-
const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration)})` : '';
|
|
379
|
-
const retry = result.retryCount ? utils.$_.yellow(` (retry x${result.retryCount})`) : '';
|
|
380
|
-
console.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}${retry}`);
|
|
381
|
-
if (result.errors) for (const error of result.errors)console.error(utils.$_.red(` ${error.message}`));
|
|
388
|
+
if (showAllCases || 'fail' === result.status || isSlowCase || retried) logCase(result, slowTestThreshold);
|
|
382
389
|
}
|
|
383
390
|
}
|
|
384
391
|
onTestCaseResult(_result) {}
|
|
@@ -420,14 +427,76 @@ export const __webpack_modules__ = {
|
|
|
420
427
|
});
|
|
421
428
|
}
|
|
422
429
|
}
|
|
430
|
+
class GithubActionsReporter {
|
|
431
|
+
onWritePath;
|
|
432
|
+
rootPath;
|
|
433
|
+
constructor({ options, rootPath }){
|
|
434
|
+
this.onWritePath = options.onWritePath;
|
|
435
|
+
this.rootPath = rootPath;
|
|
436
|
+
}
|
|
437
|
+
async onTestRunEnd({ results, testResults, getSourcemap }) {
|
|
438
|
+
const failedTests = [
|
|
439
|
+
...results.filter((i)=>'fail' === i.status && i.errors?.length),
|
|
440
|
+
...testResults.filter((i)=>'fail' === i.status)
|
|
441
|
+
];
|
|
442
|
+
if (0 === failedTests.length) return;
|
|
443
|
+
const { parseErrorStacktrace } = await Promise.all([
|
|
444
|
+
__webpack_require__.e("723"),
|
|
445
|
+
__webpack_require__.e("355")
|
|
446
|
+
]).then(__webpack_require__.bind(__webpack_require__, "./src/utils/error.ts"));
|
|
447
|
+
for (const test of failedTests){
|
|
448
|
+
const { testPath } = test;
|
|
449
|
+
const nameStr = (0, utils.Yz)(test);
|
|
450
|
+
const shortPath = (0, external_pathe_.relative)(this.rootPath, testPath);
|
|
451
|
+
const title = `${shortPath} ${utils.Qd} ${nameStr}`;
|
|
452
|
+
for (const error of test.errors || []){
|
|
453
|
+
let file = testPath;
|
|
454
|
+
let line = 1;
|
|
455
|
+
let column = 1;
|
|
456
|
+
const message = `${error.message}${error.diff ? `\n${error.diff}` : ''}`;
|
|
457
|
+
const type = 'error';
|
|
458
|
+
if (error.stack) {
|
|
459
|
+
const stackFrames = await parseErrorStacktrace({
|
|
460
|
+
stack: error.stack,
|
|
461
|
+
fullStack: error.fullStack,
|
|
462
|
+
getSourcemap
|
|
463
|
+
});
|
|
464
|
+
if (stackFrames[0]) {
|
|
465
|
+
file = stackFrames[0].file || test.testPath;
|
|
466
|
+
line = stackFrames[0].lineNumber || 1;
|
|
467
|
+
column = stackFrames[0].column || 1;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
utils.kg.log(`::${type} file=${this.onWritePath?.(file) || file},line=${line},col=${column},title=${escapeData(title)}::${escapeData(message)}`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
function escapeData(s) {
|
|
476
|
+
return s.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/:/g, '%3A').replace(/,/g, '%2C');
|
|
477
|
+
}
|
|
478
|
+
class VerboseReporter extends DefaultReporter {
|
|
479
|
+
onTestFileResult(test) {
|
|
480
|
+
this.statusRenderer?.removeRunningModule(test.testPath);
|
|
481
|
+
const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
|
|
482
|
+
const { slowTestThreshold } = this.config;
|
|
483
|
+
logFileTitle(test, relativePath, slowTestThreshold, true);
|
|
484
|
+
for (const result of test.results)logCase(result, slowTestThreshold);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
423
487
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
424
488
|
const reportersMap = {
|
|
425
|
-
default: DefaultReporter
|
|
489
|
+
default: DefaultReporter,
|
|
490
|
+
verbose: VerboseReporter,
|
|
491
|
+
'github-actions': GithubActionsReporter
|
|
426
492
|
};
|
|
427
493
|
function createReporters(reporters, initOptions = {}) {
|
|
428
494
|
const result = (0, helper.XQ)(reporters).map((reporter)=>{
|
|
429
495
|
if ('string' == typeof reporter || Array.isArray(reporter)) {
|
|
430
|
-
const [name, options = {}] =
|
|
496
|
+
const [name, options = {}] = 'string' == typeof reporter ? [
|
|
497
|
+
reporter,
|
|
498
|
+
{}
|
|
499
|
+
] : reporter;
|
|
431
500
|
if (name in reportersMap) {
|
|
432
501
|
const Reporter = reportersMap[name];
|
|
433
502
|
return new Reporter({
|
|
@@ -454,7 +523,7 @@ export const __webpack_modules__ = {
|
|
|
454
523
|
});
|
|
455
524
|
return {
|
|
456
525
|
command,
|
|
457
|
-
version: "0.0
|
|
526
|
+
version: "0.1.0",
|
|
458
527
|
rootPath,
|
|
459
528
|
reporters,
|
|
460
529
|
snapshotManager,
|
package/dist/cli.js
CHANGED
|
@@ -233,7 +233,7 @@ var __webpack_modules__ = {
|
|
|
233
233
|
value: true
|
|
234
234
|
});
|
|
235
235
|
exports.build = void 0;
|
|
236
|
-
const fs_1 = __importDefault(__webpack_require__("fs"));
|
|
236
|
+
const fs_1 = __importDefault(__webpack_require__("node:fs"));
|
|
237
237
|
const path_1 = __webpack_require__("node:path");
|
|
238
238
|
const resolveSymlinksAsync = function(path, state, callback) {
|
|
239
239
|
const { queue, options: { suppressErrors } } = state;
|
|
@@ -292,7 +292,7 @@ var __webpack_modules__ = {
|
|
|
292
292
|
value: true
|
|
293
293
|
});
|
|
294
294
|
exports.build = void 0;
|
|
295
|
-
const fs_1 = __importDefault(__webpack_require__("fs"));
|
|
295
|
+
const fs_1 = __importDefault(__webpack_require__("node:fs"));
|
|
296
296
|
const readdirOpts = {
|
|
297
297
|
withFileTypes: true
|
|
298
298
|
};
|
|
@@ -2180,7 +2180,7 @@ var __webpack_modules__ = {
|
|
|
2180
2180
|
ME: ()=>loadConfig,
|
|
2181
2181
|
hY: ()=>withDefaultConfig
|
|
2182
2182
|
});
|
|
2183
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
2183
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
2184
2184
|
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
2185
2185
|
var pathe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("pathe");
|
|
2186
2186
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
@@ -2239,7 +2239,10 @@ var __webpack_modules__ = {
|
|
|
2239
2239
|
hookTimeout: 10000,
|
|
2240
2240
|
testEnvironment: 'node',
|
|
2241
2241
|
retry: 0,
|
|
2242
|
-
reporters: [
|
|
2242
|
+
reporters: 'true' === process.env.GITHUB_ACTIONS ? [
|
|
2243
|
+
'default',
|
|
2244
|
+
'github-actions'
|
|
2245
|
+
] : [
|
|
2243
2246
|
'default'
|
|
2244
2247
|
],
|
|
2245
2248
|
clearMocks: false,
|
|
@@ -2463,7 +2466,7 @@ var __webpack_modules__ = {
|
|
|
2463
2466
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
2464
2467
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
2465
2468
|
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
2466
|
-
var external_node_fs_ = __webpack_require__("fs");
|
|
2469
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
2467
2470
|
var promises_ = __webpack_require__("node:fs/promises");
|
|
2468
2471
|
var external_node_module_ = __webpack_require__("node:module");
|
|
2469
2472
|
var external_pathe_ = __webpack_require__("pathe");
|
|
@@ -2848,7 +2851,7 @@ var __webpack_modules__ = {
|
|
|
2848
2851
|
"node:events": function(module) {
|
|
2849
2852
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__;
|
|
2850
2853
|
},
|
|
2851
|
-
fs: function(module) {
|
|
2854
|
+
"node:fs": function(module) {
|
|
2852
2855
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
2853
2856
|
},
|
|
2854
2857
|
"node:fs/promises": function(module) {
|
|
@@ -3690,13 +3693,13 @@ function prepareCli() {
|
|
|
3690
3693
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
3691
3694
|
}
|
|
3692
3695
|
function showRstest() {
|
|
3693
|
-
logger.k.greet(" Rstest v0.0
|
|
3696
|
+
logger.k.greet(" Rstest v0.1.0");
|
|
3694
3697
|
logger.k.log('');
|
|
3695
3698
|
}
|
|
3696
3699
|
const applyCommonOptions = (cli)=>{
|
|
3697
3700
|
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`', {
|
|
3698
3701
|
default: 'jiti'
|
|
3699
|
-
}).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('--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('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').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('--retry <retry>', 'Number of times to retry a test if it fails').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');
|
|
3702
|
+
}).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('--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('--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('--retry <retry>', 'Number of times to retry a test if it fails').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');
|
|
3700
3703
|
};
|
|
3701
3704
|
async function initCli(options) {
|
|
3702
3705
|
const cwd = process.cwd();
|
|
@@ -3729,6 +3732,7 @@ async function initCli(options) {
|
|
|
3729
3732
|
];
|
|
3730
3733
|
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
3731
3734
|
if (options.exclude) config.exclude = (0, helper.XQ)(options.exclude);
|
|
3735
|
+
if (options.reporter) config.reporters = (0, helper.XQ)(options.reporter);
|
|
3732
3736
|
if (options.include) config.include = (0, helper.XQ)(options.include);
|
|
3733
3737
|
return {
|
|
3734
3738
|
config,
|
|
@@ -3738,7 +3742,7 @@ async function initCli(options) {
|
|
|
3738
3742
|
function setupCommands() {
|
|
3739
3743
|
const cli = dist('rstest');
|
|
3740
3744
|
cli.help();
|
|
3741
|
-
cli.version("0.0
|
|
3745
|
+
cli.version("0.1.0");
|
|
3742
3746
|
applyCommonOptions(cli);
|
|
3743
3747
|
cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
|
|
3744
3748
|
showRstest();
|
|
@@ -3749,7 +3753,7 @@ function setupCommands() {
|
|
|
3749
3753
|
let rstest;
|
|
3750
3754
|
try {
|
|
3751
3755
|
const { config } = await initCli(options);
|
|
3752
|
-
const { createRstest } = await __webpack_require__.e("
|
|
3756
|
+
const { createRstest } = await __webpack_require__.e("950").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3753
3757
|
rstest = createRstest(config, command, filters.map(external_pathe_.normalize));
|
|
3754
3758
|
await rstest.runTests();
|
|
3755
3759
|
} catch (err) {
|
|
@@ -3770,7 +3774,7 @@ function setupCommands() {
|
|
|
3770
3774
|
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)=>{
|
|
3771
3775
|
try {
|
|
3772
3776
|
const { config } = await initCli(options);
|
|
3773
|
-
const { createRstest } = await __webpack_require__.e("
|
|
3777
|
+
const { createRstest } = await __webpack_require__.e("950").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3774
3778
|
const rstest = createRstest(config, 'list', filters.map(external_pathe_.normalize));
|
|
3775
3779
|
await rstest.listTests({
|
|
3776
3780
|
filesOnly: options.filesOnly,
|
package/dist/worker.js
CHANGED
|
@@ -5414,7 +5414,7 @@ var __webpack_modules__ = {
|
|
|
5414
5414
|
"node:console": function(module) {
|
|
5415
5415
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
|
|
5416
5416
|
},
|
|
5417
|
-
fs: function(module) {
|
|
5417
|
+
"node:fs": function(module) {
|
|
5418
5418
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
5419
5419
|
},
|
|
5420
5420
|
"node:fs/promises": function(module) {
|
|
@@ -5568,6 +5568,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
5568
5568
|
};
|
|
5569
5569
|
})();
|
|
5570
5570
|
__webpack_require__("./src/runtime/worker/setup.ts");
|
|
5571
|
+
var external_node_timers_ = __webpack_require__("node:timers");
|
|
5571
5572
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
5572
5573
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
5573
5574
|
var util = __webpack_require__("./src/runtime/util.ts");
|
|
@@ -5815,13 +5816,14 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5815
5816
|
listeners.length = 0;
|
|
5816
5817
|
const unhandledErrors = [];
|
|
5817
5818
|
const handleError = (e, type)=>{
|
|
5818
|
-
|
|
5819
|
+
const error = 'string' == typeof e ? new Error(e) : e;
|
|
5820
|
+
error.name = type;
|
|
5819
5821
|
if (isTeardown) {
|
|
5820
|
-
|
|
5821
|
-
console.error(
|
|
5822
|
+
error.stack = `${helper.$_.yellow('Caught error after test environment was torn down:')}\n\n${error.stack}`;
|
|
5823
|
+
console.error(error);
|
|
5822
5824
|
} else {
|
|
5823
|
-
console.error(
|
|
5824
|
-
unhandledErrors.push(
|
|
5825
|
+
console.error(error);
|
|
5826
|
+
unhandledErrors.push(error);
|
|
5825
5827
|
}
|
|
5826
5828
|
};
|
|
5827
5829
|
const uncaughtException = (e)=>handleError(e, 'uncaughtException');
|
|
@@ -5908,6 +5910,7 @@ const runInPool = async (options)=>{
|
|
|
5908
5910
|
});
|
|
5909
5911
|
process.off('SIGTERM', onExit);
|
|
5910
5912
|
const teardown = async ()=>{
|
|
5913
|
+
await new Promise((resolve)=>(0, external_node_timers_.setTimeout)(resolve));
|
|
5911
5914
|
await Promise.all(cleanups.map((fn)=>fn()));
|
|
5912
5915
|
isTeardown = true;
|
|
5913
5916
|
process.once('SIGTERM', onExit);
|
package/dist-types/node.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ declare interface DecodedSourceMap extends SourceMapV3 {
|
|
|
15
15
|
declare type DecodedSourceMapXInput = DecodedSourceMap & XInput;
|
|
16
16
|
|
|
17
17
|
declare class DefaultReporter implements Reporter {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
protected rootPath: string;
|
|
19
|
+
protected config: NormalizedConfig;
|
|
20
20
|
private options;
|
|
21
|
-
|
|
21
|
+
protected statusRenderer: StatusRenderer | undefined;
|
|
22
22
|
constructor({ rootPath, options, config, }: {
|
|
23
23
|
rootPath: string;
|
|
24
24
|
config: NormalizedConfig;
|
|
@@ -70,6 +70,24 @@ declare type GeneratedColumn = number;
|
|
|
70
70
|
|
|
71
71
|
declare type GetSourcemap = (sourcePath: string) => SourceMapInput | null;
|
|
72
72
|
|
|
73
|
+
declare class GithubActionsReporter {
|
|
74
|
+
private onWritePath;
|
|
75
|
+
private rootPath;
|
|
76
|
+
constructor({ options, rootPath, }: {
|
|
77
|
+
rootPath: string;
|
|
78
|
+
options: {
|
|
79
|
+
onWritePath: (path: string) => string;
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
83
|
+
results: TestFileResult[];
|
|
84
|
+
testResults: TestResult[];
|
|
85
|
+
duration: Duration;
|
|
86
|
+
snapshotSummary: SnapshotSummary;
|
|
87
|
+
getSourcemap: GetSourcemap;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
|
|
73
91
|
declare type MaybePromise<T> = T | Promise<T>;
|
|
74
92
|
|
|
75
93
|
declare type NamesIndex = number;
|
|
@@ -117,6 +135,8 @@ export declare interface Reporter {
|
|
|
117
135
|
|
|
118
136
|
declare const reportersMap: {
|
|
119
137
|
default: typeof DefaultReporter;
|
|
138
|
+
verbose: typeof VerboseReporter;
|
|
139
|
+
'github-actions': typeof GithubActionsReporter;
|
|
120
140
|
};
|
|
121
141
|
|
|
122
142
|
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
@@ -328,6 +348,17 @@ declare interface SourceMapV3 {
|
|
|
328
348
|
|
|
329
349
|
declare type SourcesIndex = number;
|
|
330
350
|
|
|
351
|
+
declare class StatusRenderer {
|
|
352
|
+
private rootPath;
|
|
353
|
+
private renderer;
|
|
354
|
+
private runningModules;
|
|
355
|
+
constructor(rootPath: string);
|
|
356
|
+
getContent(): string[];
|
|
357
|
+
addRunningModule(testPath: string): void;
|
|
358
|
+
removeRunningModule(testPath: string): void;
|
|
359
|
+
clear(): void;
|
|
360
|
+
}
|
|
361
|
+
|
|
331
362
|
export declare type TestFileInfo = {
|
|
332
363
|
testPath: TestPath;
|
|
333
364
|
};
|
|
@@ -377,6 +408,10 @@ declare interface UserConsoleLog {
|
|
|
377
408
|
type: 'stdout' | 'stderr';
|
|
378
409
|
}
|
|
379
410
|
|
|
411
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
412
|
+
onTestFileResult(test: TestFileResult): void;
|
|
413
|
+
}
|
|
414
|
+
|
|
380
415
|
declare type XInput = {
|
|
381
416
|
x_google_ignoreList?: SourceMapV3['ignoreList'];
|
|
382
417
|
};
|
package/dist-types/public.d.ts
CHANGED
|
@@ -93,10 +93,10 @@ declare interface DecodedSourceMap extends SourceMapV3 {
|
|
|
93
93
|
declare type DecodedSourceMapXInput = DecodedSourceMap & XInput;
|
|
94
94
|
|
|
95
95
|
declare class DefaultReporter implements Reporter {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
protected rootPath: string;
|
|
97
|
+
protected config: NormalizedConfig;
|
|
98
98
|
private options;
|
|
99
|
-
|
|
99
|
+
protected statusRenderer: StatusRenderer | undefined;
|
|
100
100
|
constructor({ rootPath, options, config, }: {
|
|
101
101
|
rootPath: string;
|
|
102
102
|
config: NormalizedConfig;
|
|
@@ -283,6 +283,24 @@ declare type GeneratedColumn = number;
|
|
|
283
283
|
|
|
284
284
|
declare type GetSourcemap = (sourcePath: string) => SourceMapInput | null;
|
|
285
285
|
|
|
286
|
+
declare class GithubActionsReporter {
|
|
287
|
+
private onWritePath;
|
|
288
|
+
private rootPath;
|
|
289
|
+
constructor({ options, rootPath, }: {
|
|
290
|
+
rootPath: string;
|
|
291
|
+
options: {
|
|
292
|
+
onWritePath: (path: string) => string;
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
296
|
+
results: TestFileResult[];
|
|
297
|
+
testResults: TestResult[];
|
|
298
|
+
duration: Duration;
|
|
299
|
+
snapshotSummary: SnapshotSummary;
|
|
300
|
+
getSourcemap: GetSourcemap;
|
|
301
|
+
}): Promise<void>;
|
|
302
|
+
}
|
|
303
|
+
|
|
286
304
|
declare interface InlineSnapshotMatcher<T> {
|
|
287
305
|
<U extends {
|
|
288
306
|
[P in keyof T]: any;
|
|
@@ -501,6 +519,8 @@ declare interface Reporter {
|
|
|
501
519
|
|
|
502
520
|
declare const reportersMap: {
|
|
503
521
|
default: typeof DefaultReporter;
|
|
522
|
+
verbose: typeof VerboseReporter;
|
|
523
|
+
'github-actions': typeof GithubActionsReporter;
|
|
504
524
|
};
|
|
505
525
|
|
|
506
526
|
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
@@ -896,6 +916,17 @@ declare interface SourceMapV3 {
|
|
|
896
916
|
|
|
897
917
|
declare type SourcesIndex = number;
|
|
898
918
|
|
|
919
|
+
declare class StatusRenderer {
|
|
920
|
+
private rootPath;
|
|
921
|
+
private renderer;
|
|
922
|
+
private runningModules;
|
|
923
|
+
constructor(rootPath: string);
|
|
924
|
+
getContent(): string[];
|
|
925
|
+
addRunningModule(testPath: string): void;
|
|
926
|
+
removeRunningModule(testPath: string): void;
|
|
927
|
+
clear(): void;
|
|
928
|
+
}
|
|
929
|
+
|
|
899
930
|
declare type SuiteContext = {
|
|
900
931
|
filepath: TestPath;
|
|
901
932
|
};
|
|
@@ -987,6 +1018,10 @@ declare interface UserConsoleLog {
|
|
|
987
1018
|
type: 'stdout' | 'stderr';
|
|
988
1019
|
}
|
|
989
1020
|
|
|
1021
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
1022
|
+
onTestFileResult(test: TestFileResult): void;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
990
1025
|
declare type XInput = {
|
|
991
1026
|
x_google_ignoreList?: SourceMapV3['ignoreList'];
|
|
992
1027
|
};
|
package/dist-types/worker.d.ts
CHANGED
|
@@ -83,10 +83,10 @@ declare interface DecodedSourceMap extends SourceMapV3 {
|
|
|
83
83
|
declare type DecodedSourceMapXInput = DecodedSourceMap & XInput;
|
|
84
84
|
|
|
85
85
|
declare class DefaultReporter implements Reporter {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
protected rootPath: string;
|
|
87
|
+
protected config: NormalizedConfig;
|
|
88
88
|
private options;
|
|
89
|
-
|
|
89
|
+
protected statusRenderer: StatusRenderer | undefined;
|
|
90
90
|
constructor({ rootPath, options, config, }: {
|
|
91
91
|
rootPath: string;
|
|
92
92
|
config: NormalizedConfig;
|
|
@@ -181,6 +181,24 @@ declare type GeneratedColumn = number;
|
|
|
181
181
|
|
|
182
182
|
declare type GetSourcemap = (sourcePath: string) => SourceMapInput | null;
|
|
183
183
|
|
|
184
|
+
declare class GithubActionsReporter {
|
|
185
|
+
private onWritePath;
|
|
186
|
+
private rootPath;
|
|
187
|
+
constructor({ options, rootPath, }: {
|
|
188
|
+
rootPath: string;
|
|
189
|
+
options: {
|
|
190
|
+
onWritePath: (path: string) => string;
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
194
|
+
results: TestFileResult[];
|
|
195
|
+
testResults: TestResult[];
|
|
196
|
+
duration: Duration;
|
|
197
|
+
snapshotSummary: SnapshotSummary;
|
|
198
|
+
getSourcemap: GetSourcemap;
|
|
199
|
+
}): Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
|
|
184
202
|
declare interface InlineSnapshotMatcher<T> {
|
|
185
203
|
<U extends {
|
|
186
204
|
[P in keyof T]: any;
|
|
@@ -255,6 +273,8 @@ declare interface Reporter {
|
|
|
255
273
|
|
|
256
274
|
declare const reportersMap: {
|
|
257
275
|
default: typeof DefaultReporter;
|
|
276
|
+
verbose: typeof VerboseReporter;
|
|
277
|
+
'github-actions': typeof GithubActionsReporter;
|
|
258
278
|
};
|
|
259
279
|
|
|
260
280
|
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
@@ -524,6 +544,17 @@ declare interface SourceMapV3 {
|
|
|
524
544
|
|
|
525
545
|
declare type SourcesIndex = number;
|
|
526
546
|
|
|
547
|
+
declare class StatusRenderer {
|
|
548
|
+
private rootPath;
|
|
549
|
+
private renderer;
|
|
550
|
+
private runningModules;
|
|
551
|
+
constructor(rootPath: string);
|
|
552
|
+
getContent(): string[];
|
|
553
|
+
addRunningModule(testPath: string): void;
|
|
554
|
+
removeRunningModule(testPath: string): void;
|
|
555
|
+
clear(): void;
|
|
556
|
+
}
|
|
557
|
+
|
|
527
558
|
declare type SuiteContext = {
|
|
528
559
|
filepath: TestPath;
|
|
529
560
|
};
|
|
@@ -650,6 +681,10 @@ declare interface UserConsoleLog {
|
|
|
650
681
|
type: 'stdout' | 'stderr';
|
|
651
682
|
}
|
|
652
683
|
|
|
684
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
685
|
+
onTestFileResult(test: TestFileResult): void;
|
|
686
|
+
}
|
|
687
|
+
|
|
653
688
|
declare type WorkerContext = {
|
|
654
689
|
rootPath: RstestContext['rootPath'];
|
|
655
690
|
runtimeConfig: RuntimeConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"importMeta.d.ts"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@rsbuild/core": "1.4.
|
|
51
|
+
"@rsbuild/core": "1.4.12",
|
|
52
52
|
"@types/chai": "^5.2.2",
|
|
53
53
|
"@vitest/expect": "^3.2.4",
|
|
54
54
|
"@vitest/snapshot": "^3.2.4",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@babel/code-frame": "^7.27.1",
|
|
63
63
|
"@jridgewell/trace-mapping": "0.3.29",
|
|
64
|
-
"@microsoft/api-extractor": "^7.52.
|
|
64
|
+
"@microsoft/api-extractor": "^7.52.10",
|
|
65
65
|
"@rslib/core": "0.11.0",
|
|
66
66
|
"@sinonjs/fake-timers": "^14.0.0",
|
|
67
67
|
"@types/babel__code-frame": "^7.0.6",
|