@rstest/core 0.7.3 → 0.7.4
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~130.js +2 -1
- package/dist/0~151.js +18 -21
- package/dist/0~173.js +43 -6
- package/dist/0~255.js +2 -2
- package/dist/0~403.js +2 -1
- package/dist/0~426.js +5 -3
- package/dist/0~583.js +4 -3
- package/dist/0~588.js +5 -3
- package/dist/0~62.js +1 -1
- package/dist/0~634.js +52 -8
- package/dist/0~809.js +1 -1
- package/dist/0~835.js +4 -3
- package/dist/{0~122.js → 0~89.js} +117 -19
- package/dist/0~919.js +1 -1
- package/dist/0~923.js +4 -3
- package/dist/131.js +36 -18
- package/dist/{946.js → 157.js} +11 -854
- package/dist/198.js +4 -0
- package/dist/{404.js → 216.js} +1 -2
- package/dist/278.js +765 -0
- package/dist/554.js +6 -6715
- package/dist/664.js +93 -0
- package/dist/734.js +4 -3
- package/dist/913.js +6717 -0
- package/dist/globalSetupWorker.d.ts +9 -0
- package/dist/globalSetupWorker.js +115 -0
- package/dist/index.d.ts +152 -21
- package/dist/index.js +1 -1
- package/dist/worker.d.ts +150 -21
- package/package.json +2 -1
- /package/dist/{554.js.LICENSE.txt → 913.js.LICENSE.txt} +0 -0
|
@@ -4,8 +4,11 @@ import { __webpack_require__ } from "./rslib-runtime.js";
|
|
|
4
4
|
import node_events from "node:events";
|
|
5
5
|
import { Tinypool } from "tinypool";
|
|
6
6
|
import node_inspector from "node:inspector";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { isBuiltin } from "./664.js";
|
|
8
|
+
import { node_process, basename, isDebug, dirname, posix, resolve as pathe_M_eThtNZ_resolve, join } from "./278.js";
|
|
9
|
+
import { fileURLToPath } from "./198.js";
|
|
10
|
+
import { node_v8, createBirpc } from "./216.js";
|
|
11
|
+
import { serializableConfig, bgColor, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, castArray, ADDITIONAL_NODE_BUILTINS, needFlagExperimentalDetectModule } from "./157.js";
|
|
9
12
|
import { core_logger, createRsbuild } from "./131.js";
|
|
10
13
|
const DefaultMaxHeapSize = 1073741824;
|
|
11
14
|
function memory_isMemorySufficient(options) {
|
|
@@ -63,6 +66,8 @@ const createForksPool = (poolOptions)=>{
|
|
|
63
66
|
isolateWorkers: isolate
|
|
64
67
|
};
|
|
65
68
|
const pool = new Tinypool(options);
|
|
69
|
+
const destroy = pool.destroy.bind(pool);
|
|
70
|
+
process.on('SIGTERM', destroy);
|
|
66
71
|
return {
|
|
67
72
|
name: 'forks',
|
|
68
73
|
runTest: async ({ options, rpcMethods })=>{
|
|
@@ -85,7 +90,10 @@ const createForksPool = (poolOptions)=>{
|
|
|
85
90
|
cleanup();
|
|
86
91
|
}
|
|
87
92
|
},
|
|
88
|
-
close: ()=>
|
|
93
|
+
close: ()=>{
|
|
94
|
+
process.off('SIGTERM', destroy);
|
|
95
|
+
return destroy();
|
|
96
|
+
}
|
|
89
97
|
};
|
|
90
98
|
};
|
|
91
99
|
const external_node_os_ = __webpack_require__("node:os");
|
|
@@ -104,7 +112,10 @@ const parseWorkers = (maxWorkers)=>{
|
|
|
104
112
|
const getRuntimeConfig = (context)=>{
|
|
105
113
|
const { testNamePattern, testTimeout, passWithNoTests, retry, globals, clearMocks, resetMocks, restoreMocks, unstubEnvs, unstubGlobals, maxConcurrency, printConsoleTrace, disableConsoleIntercept, testEnvironment, hookTimeout, isolate, coverage, snapshotFormat, env, logHeapUsage, bail, chaiConfig, includeTaskLocation } = context.normalizedConfig;
|
|
106
114
|
return {
|
|
107
|
-
env
|
|
115
|
+
env: {
|
|
116
|
+
...process.env,
|
|
117
|
+
...env
|
|
118
|
+
},
|
|
108
119
|
testNamePattern,
|
|
109
120
|
testTimeout,
|
|
110
121
|
hookTimeout,
|
|
@@ -121,7 +132,10 @@ const getRuntimeConfig = (context)=>{
|
|
|
121
132
|
disableConsoleIntercept,
|
|
122
133
|
testEnvironment,
|
|
123
134
|
isolate,
|
|
124
|
-
coverage
|
|
135
|
+
coverage: {
|
|
136
|
+
...coverage,
|
|
137
|
+
reporters: []
|
|
138
|
+
},
|
|
125
139
|
snapshotFormat,
|
|
126
140
|
logHeapUsage,
|
|
127
141
|
bail,
|
|
@@ -165,8 +179,7 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
165
179
|
].filter(Boolean),
|
|
166
180
|
env: {
|
|
167
181
|
NODE_ENV: 'test',
|
|
168
|
-
FORCE_COLOR: '1' === process.env.NO_COLOR ? '0' : '1'
|
|
169
|
-
...process.env
|
|
182
|
+
FORCE_COLOR: '1' === process.env.NO_COLOR ? '0' : '1'
|
|
170
183
|
}
|
|
171
184
|
});
|
|
172
185
|
const rpcMethods = {
|
|
@@ -313,6 +326,78 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
313
326
|
close: ()=>pool.close()
|
|
314
327
|
};
|
|
315
328
|
};
|
|
329
|
+
let globalTeardownCallbacks = [];
|
|
330
|
+
function applyEnvChanges(changes) {
|
|
331
|
+
for(const key in changes)if (void 0 === changes[key]) delete process.env[key];
|
|
332
|
+
else process.env[key] = changes[key];
|
|
333
|
+
}
|
|
334
|
+
const globalSetup_filename = fileURLToPath(import.meta.url);
|
|
335
|
+
const globalSetup_dirname = dirname(globalSetup_filename);
|
|
336
|
+
async function createSetupPool() {
|
|
337
|
+
const options = {
|
|
338
|
+
runtime: 'child_process',
|
|
339
|
+
filename: pathe_M_eThtNZ_resolve(globalSetup_dirname, './globalSetupWorker.js'),
|
|
340
|
+
execArgv: [
|
|
341
|
+
...process.execArgv,
|
|
342
|
+
'--experimental-vm-modules',
|
|
343
|
+
'--experimental-import-meta-resolve',
|
|
344
|
+
'--no-warnings'
|
|
345
|
+
],
|
|
346
|
+
maxThreads: 1,
|
|
347
|
+
minThreads: 1,
|
|
348
|
+
concurrentTasksPerWorker: 1,
|
|
349
|
+
isolateWorkers: false,
|
|
350
|
+
env: {
|
|
351
|
+
NODE_ENV: 'test',
|
|
352
|
+
FORCE_COLOR: '1' === process.env.NO_COLOR ? '0' : '1',
|
|
353
|
+
...process.env
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
const pool = new Tinypool(options);
|
|
357
|
+
const destroy = pool.destroy.bind(pool);
|
|
358
|
+
process.on('SIGTERM', destroy);
|
|
359
|
+
return pool;
|
|
360
|
+
}
|
|
361
|
+
async function runGlobalSetup({ globalSetupEntries, assetFiles, sourceMaps, interopDefault, outputModule }) {
|
|
362
|
+
const pool = await createSetupPool();
|
|
363
|
+
const result = await pool.run({
|
|
364
|
+
type: 'setup',
|
|
365
|
+
entries: globalSetupEntries,
|
|
366
|
+
assetFiles,
|
|
367
|
+
interopDefault,
|
|
368
|
+
outputModule,
|
|
369
|
+
sourceMaps
|
|
370
|
+
});
|
|
371
|
+
if (result.success) {
|
|
372
|
+
if (result.envChanges) applyEnvChanges(result.envChanges);
|
|
373
|
+
if (result.hasTeardown) globalTeardownCallbacks.push(()=>runWorkerTeardown(pool));
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
success: result.success,
|
|
377
|
+
errors: result.errors
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
async function runWorkerTeardown(pool) {
|
|
381
|
+
const result = await pool.run({
|
|
382
|
+
type: 'teardown'
|
|
383
|
+
});
|
|
384
|
+
if (!result.success) process.exitCode = 1;
|
|
385
|
+
await pool.destroy();
|
|
386
|
+
}
|
|
387
|
+
async function runGlobalTeardown() {
|
|
388
|
+
const teardownCallbacks = [
|
|
389
|
+
...globalTeardownCallbacks
|
|
390
|
+
];
|
|
391
|
+
globalTeardownCallbacks = [];
|
|
392
|
+
for (const teardown of teardownCallbacks.reverse())try {
|
|
393
|
+
await teardown();
|
|
394
|
+
} catch (error) {
|
|
395
|
+
console.error(bgColor('bgRed', 'Error during global teardown'));
|
|
396
|
+
if (error instanceof Error) error.stack ? console.error(picocolors_default().red(error.stack)) : console.error(picocolors_default().red(error.message));
|
|
397
|
+
else console.error(picocolors_default().red(String(error)));
|
|
398
|
+
process.exitCode = 1;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
316
401
|
const RUNTIME_CHUNK_NAME = 'runtime';
|
|
317
402
|
const requireShim = `// Rstest ESM shims
|
|
318
403
|
import __rstest_shim_module__ from 'node:module';
|
|
@@ -417,7 +502,7 @@ const pluginBasic = (context)=>({
|
|
|
417
502
|
});
|
|
418
503
|
}
|
|
419
504
|
});
|
|
420
|
-
const external_node_path_ = __webpack_require__("path");
|
|
505
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
421
506
|
const PLUGIN_CSS_FILTER = 'rstest:css-filter';
|
|
422
507
|
const css_filter_dirname = external_node_path_["default"].dirname(fileURLToPath(import.meta.url));
|
|
423
508
|
const pluginCSSFilter = ()=>({
|
|
@@ -461,7 +546,7 @@ class TestFileWatchPlugin {
|
|
|
461
546
|
});
|
|
462
547
|
}
|
|
463
548
|
}
|
|
464
|
-
const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context })=>({
|
|
549
|
+
const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, globalSetupFiles, context })=>({
|
|
465
550
|
name: 'rstest:entry-watch',
|
|
466
551
|
setup: (api)=>{
|
|
467
552
|
api.modifyRspackConfig(async (config, { environment })=>{
|
|
@@ -471,13 +556,14 @@ const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context
|
|
|
471
556
|
const sourceEntries = await globTestSourceEntries(environment.name);
|
|
472
557
|
return {
|
|
473
558
|
...sourceEntries,
|
|
474
|
-
...setupFiles[environment.name]
|
|
559
|
+
...setupFiles[environment.name],
|
|
560
|
+
...globalSetupFiles?.[environment.name] || {}
|
|
475
561
|
};
|
|
476
562
|
};
|
|
477
563
|
config.watchOptions ??= {};
|
|
478
564
|
config.watchOptions.ignored = castArray(config.watchOptions.ignored || []);
|
|
479
565
|
if (0 === config.watchOptions.ignored.length) config.watchOptions.ignored.push('**/.git', '**/node_modules');
|
|
480
|
-
config.watchOptions.ignored.push(TEMP_RSTEST_OUTPUT_DIR_GLOB, context.normalizedConfig.coverage.reportsDirectory, '**/*.snap');
|
|
566
|
+
config.watchOptions.ignored.push(TEMP_RSTEST_OUTPUT_DIR_GLOB, context.normalizedConfig.coverage.reportsDirectory, ...Object.values(globalSetupFiles?.[environment.name] || {}), '**/*.snap');
|
|
481
567
|
const configFilePath = context.projects.find((project)=>project.environmentName === environment.name)?.configFilePath;
|
|
482
568
|
if (configFilePath) config.watchOptions.ignored.push(configFilePath);
|
|
483
569
|
} else {
|
|
@@ -487,6 +573,7 @@ const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context
|
|
|
487
573
|
const sourceEntries = await globTestSourceEntries(environment.name);
|
|
488
574
|
config.entry = {
|
|
489
575
|
...setupFiles[environment.name],
|
|
576
|
+
...globalSetupFiles?.[environment.name] || {},
|
|
490
577
|
...sourceEntries
|
|
491
578
|
};
|
|
492
579
|
}
|
|
@@ -576,7 +663,7 @@ const pluginInspect = ()=>enable ? {
|
|
|
576
663
|
});
|
|
577
664
|
}
|
|
578
665
|
} : null;
|
|
579
|
-
const external_node_fs_ = __webpack_require__("
|
|
666
|
+
const external_node_fs_ = __webpack_require__("fs");
|
|
580
667
|
const mockRuntime_dirname = external_node_path_["default"].dirname(fileURLToPath(import.meta.url));
|
|
581
668
|
class MockRuntimeRspackPlugin {
|
|
582
669
|
outputModule;
|
|
@@ -694,7 +781,7 @@ function parseInlineSourceMapStr(code) {
|
|
|
694
781
|
}
|
|
695
782
|
}
|
|
696
783
|
const isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isArray(compiler.compilers);
|
|
697
|
-
const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
|
|
784
|
+
const prepareRsbuild = async (context, globTestSourceEntries, setupFiles, globalSetupFiles)=>{
|
|
698
785
|
const { command, normalizedConfig: { isolate, dev = {}, coverage } } = context;
|
|
699
786
|
const debugMode = isDebug();
|
|
700
787
|
core_logger.level = debugMode ? 'verbose' : 'error';
|
|
@@ -733,11 +820,15 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
|
|
|
733
820
|
pluginEntryWatch({
|
|
734
821
|
globTestSourceEntries,
|
|
735
822
|
setupFiles,
|
|
823
|
+
globalSetupFiles,
|
|
736
824
|
context,
|
|
737
825
|
isWatch: 'watch' === command
|
|
738
826
|
}),
|
|
739
827
|
pluginExternal(context),
|
|
740
|
-
!isolate ? pluginCacheControl(Object.values(
|
|
828
|
+
!isolate ? pluginCacheControl(Object.values({
|
|
829
|
+
...setupFiles,
|
|
830
|
+
...globalSetupFiles
|
|
831
|
+
}).flatMap((files)=>Object.values(files))) : null,
|
|
741
832
|
pluginInspect()
|
|
742
833
|
].filter(Boolean)
|
|
743
834
|
}
|
|
@@ -750,7 +841,7 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
|
|
|
750
841
|
pluginCoverageCore: mod.pluginCoverageCore
|
|
751
842
|
}));
|
|
752
843
|
const { pluginCoverage } = await loadCoverageProvider(coverage, context.rootPath);
|
|
753
|
-
coverage.exclude.push(...Object.values(setupFiles).flatMap((files)=>Object.values(files)));
|
|
844
|
+
coverage.exclude.push(...Object.values(setupFiles).flatMap((files)=>Object.values(files)), ...Object.values(globalSetupFiles || {}).flatMap((files)=>Object.values(files)));
|
|
754
845
|
rsbuildInstance.addPlugins([
|
|
755
846
|
pluginCoverage(coverage),
|
|
756
847
|
pluginCoverageCore(coverage)
|
|
@@ -811,7 +902,7 @@ class AssetsMemorySafeMap extends Map {
|
|
|
811
902
|
return super.set(key, value);
|
|
812
903
|
}
|
|
813
904
|
}
|
|
814
|
-
const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildInstance, inspectedConfig })=>{
|
|
905
|
+
const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, globalSetupFiles, rsbuildInstance, inspectedConfig })=>{
|
|
815
906
|
let rspackCompiler;
|
|
816
907
|
const rstestCompilerPlugin = {
|
|
817
908
|
name: 'rstest:compiler',
|
|
@@ -876,12 +967,13 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
876
967
|
const entryFiles = await getEntryFiles(manifest, outputPath);
|
|
877
968
|
const entries = [];
|
|
878
969
|
const setupEntries = [];
|
|
970
|
+
const globalSetupEntries = [];
|
|
879
971
|
const sourceEntries = await globTestSourceEntries(environmentName);
|
|
880
972
|
for (const entry of Object.keys(entrypoints)){
|
|
881
973
|
const e = entrypoints[entry];
|
|
882
974
|
const filteredAssets = e.assets.filter((asset)=>!asset.name.endsWith('.wasm'));
|
|
883
975
|
const distPath = posix.join(outputPath, filteredAssets[filteredAssets.length - 1].name);
|
|
884
|
-
if (setupFiles[environmentName][entry]) setupEntries.push({
|
|
976
|
+
if (setupFiles[environmentName]?.[entry]) setupEntries.push({
|
|
885
977
|
distPath,
|
|
886
978
|
testPath: setupFiles[environmentName][entry],
|
|
887
979
|
files: entryFiles[entry],
|
|
@@ -895,7 +987,12 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
895
987
|
files: entryFiles[entry],
|
|
896
988
|
chunks: e.chunks || []
|
|
897
989
|
});
|
|
898
|
-
}
|
|
990
|
+
} else if (globalSetupFiles?.[environmentName]?.[entry]) globalSetupEntries.push({
|
|
991
|
+
distPath,
|
|
992
|
+
testPath: globalSetupFiles[environmentName][entry],
|
|
993
|
+
files: entryFiles[entry],
|
|
994
|
+
chunks: e.chunks || []
|
|
995
|
+
});
|
|
899
996
|
}
|
|
900
997
|
const inlineSourceMap = 'inline-source-map' === stats.compilation.options.devtool;
|
|
901
998
|
const sourceMapPaths = Object.fromEntries(assets.map((asset)=>{
|
|
@@ -949,6 +1046,7 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
949
1046
|
hash,
|
|
950
1047
|
entries,
|
|
951
1048
|
setupEntries,
|
|
1049
|
+
globalSetupEntries,
|
|
952
1050
|
assetNames,
|
|
953
1051
|
getAssetFiles: async (names)=>Object.fromEntries(await Promise.all(names.map(async (name)=>{
|
|
954
1052
|
const content = await readFileWithCache(name);
|
|
@@ -971,4 +1069,4 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
971
1069
|
getRsbuildStats
|
|
972
1070
|
};
|
|
973
1071
|
};
|
|
974
|
-
export { createPool, createRsbuildServer, prepareRsbuild };
|
|
1072
|
+
export { createPool, createRsbuildServer, prepareRsbuild, runGlobalSetup, runGlobalTeardown };
|
package/dist/0~919.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import "./
|
|
4
|
+
import "./664.js";
|
|
5
5
|
__webpack_require__.add({
|
|
6
6
|
"../../node_modules/.pnpm/js-tokens@4.0.0/node_modules/js-tokens/index.js" (__unused_rspack_module, exports) {
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
package/dist/0~923.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import
|
|
5
|
-
import { pathToFileURL } from "./
|
|
4
|
+
import "./664.js";
|
|
5
|
+
import { pathToFileURL } from "./198.js";
|
|
6
6
|
import { node_vm, interopModule, shouldInterop } from "./0~346.js";
|
|
7
|
-
|
|
7
|
+
import { posix, logger_logger } from "./278.js";
|
|
8
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
8
9
|
var loadEsModule_EsmMode = /*#__PURE__*/ function(EsmMode) {
|
|
9
10
|
EsmMode[EsmMode["Unknown"] = 0] = "Unknown";
|
|
10
11
|
EsmMode[EsmMode["Evaluated"] = 1] = "Evaluated";
|
package/dist/131.js
CHANGED
|
@@ -3,7 +3,9 @@ import 'module';
|
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
4
|
import { EventEmitter } from "events";
|
|
5
5
|
import { createRsbuild, loadConfig, logger as core_logger, mergeRsbuildConfig } from "@rsbuild/core";
|
|
6
|
-
import
|
|
6
|
+
import "./664.js";
|
|
7
|
+
import { basename, logger_logger, dirname, posix, resolve as pathe_M_eThtNZ_resolve, isDebug, isAbsolute, relative, join, normalize } from "./278.js";
|
|
8
|
+
import { isTTY, DEFAULT_CONFIG_NAME, globalApis, filterProjects, getAbsolutePath, bgColor, formatRootStr, isDynamicPattern, glob, writeFile, castArray, prettyTestPath, prettyTime, TEMP_RSTEST_OUTPUT_DIR_GLOB, getTaskNameWithPrefix, formatTestPath, formatError, DEFAULT_CONFIG_EXTENSIONS, TS_CONFIG_FILE } from "./157.js";
|
|
7
9
|
import { parse as stack_trace_parser_esm_parse } from "./672.js";
|
|
8
10
|
import { decode } from "./397.js";
|
|
9
11
|
function toArr(any) {
|
|
@@ -501,7 +503,7 @@ function prepareCli() {
|
|
|
501
503
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger_logger.log();
|
|
502
504
|
}
|
|
503
505
|
function showRstest() {
|
|
504
|
-
logger_logger.greet(" Rstest v0.7.
|
|
506
|
+
logger_logger.greet(" Rstest v0.7.4");
|
|
505
507
|
logger_logger.log('');
|
|
506
508
|
}
|
|
507
509
|
const applyCommonOptions = (cli)=>{
|
|
@@ -545,7 +547,7 @@ const runRest = async ({ options, filters, command })=>{
|
|
|
545
547
|
function setupCommands() {
|
|
546
548
|
const cli = dist('rstest');
|
|
547
549
|
cli.help();
|
|
548
|
-
cli.version("0.7.
|
|
550
|
+
cli.version("0.7.4");
|
|
549
551
|
applyCommonOptions(cli);
|
|
550
552
|
cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
551
553
|
showRstest();
|
|
@@ -605,7 +607,7 @@ function setupCommands() {
|
|
|
605
607
|
});
|
|
606
608
|
cli.parse();
|
|
607
609
|
}
|
|
608
|
-
const external_node_fs_ = __webpack_require__("
|
|
610
|
+
const external_node_fs_ = __webpack_require__("fs");
|
|
609
611
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
610
612
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
611
613
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
|
|
@@ -639,6 +641,7 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, configLoa
|
|
|
639
641
|
filePath: configFilePath
|
|
640
642
|
};
|
|
641
643
|
}
|
|
644
|
+
const mergeProjectConfig = (...configs)=>mergeRstestConfig(...configs);
|
|
642
645
|
const mergeRstestConfig = (...configs)=>configs.reduce((result, config)=>{
|
|
643
646
|
const merged = mergeRsbuildConfig(result, {
|
|
644
647
|
...config,
|
|
@@ -670,6 +673,7 @@ const createDefaultConfig = ()=>({
|
|
|
670
673
|
override: false
|
|
671
674
|
},
|
|
672
675
|
setupFiles: [],
|
|
676
|
+
globalSetup: [],
|
|
673
677
|
includeSource: [],
|
|
674
678
|
pool: {
|
|
675
679
|
type: 'forks'
|
|
@@ -733,6 +737,7 @@ const createDefaultConfig = ()=>({
|
|
|
733
737
|
const withDefaultConfig = (config)=>{
|
|
734
738
|
const merged = mergeRstestConfig(createDefaultConfig(), config);
|
|
735
739
|
merged.setupFiles = castArray(merged.setupFiles);
|
|
740
|
+
merged.globalSetup = castArray(merged.globalSetup);
|
|
736
741
|
merged.exclude.patterns.push(TEMP_RSTEST_OUTPUT_DIR_GLOB);
|
|
737
742
|
const reportsDirectory = formatRootStr(merged.coverage.reportsDirectory, merged.root);
|
|
738
743
|
merged.coverage.reportsDirectory = isAbsolute(reportsDirectory) ? reportsDirectory : pathe_M_eThtNZ_resolve(merged.root, reportsDirectory);
|
|
@@ -747,6 +752,7 @@ const withDefaultConfig = (config)=>{
|
|
|
747
752
|
patterns: merged.exclude.patterns.map((p)=>formatRootStr(p, merged.root))
|
|
748
753
|
},
|
|
749
754
|
setupFiles: merged.setupFiles.map((p)=>formatRootStr(p, merged.root)),
|
|
755
|
+
globalSetup: merged.globalSetup.map((p)=>formatRootStr(p, merged.root)),
|
|
750
756
|
includeSource: merged.includeSource.map((p)=>formatRootStr(p, merged.root))
|
|
751
757
|
};
|
|
752
758
|
};
|
|
@@ -1348,15 +1354,22 @@ const printSummaryLog = ({ results, testResults, snapshotSummary, duration, root
|
|
|
1348
1354
|
logger_logger.log(`${DurationLabel} ${prettyTime(duration.totalTime)} ${picocolors_default().gray(`(build ${prettyTime(duration.buildTime)}, tests ${prettyTime(duration.testTime)})`)}`);
|
|
1349
1355
|
logger_logger.log('');
|
|
1350
1356
|
};
|
|
1351
|
-
const printSummaryErrorLogs = async ({ testResults, results, rootPath, getSourcemap, filterRerunTestPaths })=>{
|
|
1357
|
+
const printSummaryErrorLogs = async ({ testResults, results, rootPath, unhandledErrors, getSourcemap, filterRerunTestPaths })=>{
|
|
1352
1358
|
const failedTests = [
|
|
1353
1359
|
...results.filter((i)=>'fail' === i.status && i.errors?.length && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true)),
|
|
1354
1360
|
...testResults.filter((i)=>'fail' === i.status && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true))
|
|
1355
1361
|
];
|
|
1356
|
-
if (0 === failedTests.length) return;
|
|
1362
|
+
if (0 === failedTests.length && !unhandledErrors?.length) return;
|
|
1357
1363
|
logger_logger.stderr('');
|
|
1358
1364
|
logger_logger.stderr(picocolors_default().bold('Summary of all failing tests:'));
|
|
1359
1365
|
logger_logger.stderr('');
|
|
1366
|
+
const { printError } = await Promise.resolve().then(()=>({
|
|
1367
|
+
printError: error_printError
|
|
1368
|
+
}));
|
|
1369
|
+
for (const error of unhandledErrors || []){
|
|
1370
|
+
logger_logger.stderr(bgColor('bgRed', ' Unhandled Error '));
|
|
1371
|
+
await printError(error, getSourcemap, rootPath);
|
|
1372
|
+
}
|
|
1360
1373
|
for (const test of failedTests){
|
|
1361
1374
|
const relativePath = posix.relative(rootPath, test.testPath);
|
|
1362
1375
|
const nameStr = getTaskNameWithPrefix(test);
|
|
@@ -1512,7 +1525,7 @@ class StatusRenderer {
|
|
|
1512
1525
|
const testModules = this.testState.getTestModules();
|
|
1513
1526
|
const shouldDisplayRunningTests = (runningTests)=>runningTests[0]?.startTime && now - runningTests[0].startTime > 2000;
|
|
1514
1527
|
for (const [module, { runningTests }] of runningModules.entries()){
|
|
1515
|
-
const relativePath =
|
|
1528
|
+
const relativePath = relative(this.rootPath, module);
|
|
1516
1529
|
summary.push(`${bgColor('bgYellow', ' RUNS ')} ${prettyTestPath(relativePath)}`);
|
|
1517
1530
|
if (runningTests.length && shouldDisplayRunningTests(runningTests)) {
|
|
1518
1531
|
let caseLog = ` ${picocolors_default().gray("➜")} ${getTaskNameWithPrefix(runningTests[0])} ${picocolors_default().magenta(prettyTime(now - runningTests[0].startTime))}`;
|
|
@@ -1591,7 +1604,7 @@ class DefaultReporter {
|
|
|
1591
1604
|
}
|
|
1592
1605
|
onTestFileResult(test) {
|
|
1593
1606
|
this.statusRenderer?.onTestFileResult();
|
|
1594
|
-
const relativePath =
|
|
1607
|
+
const relativePath = relative(this.rootPath, test.testPath);
|
|
1595
1608
|
const { slowTestThreshold } = this.config;
|
|
1596
1609
|
logFileTitle(test, relativePath);
|
|
1597
1610
|
for (const result of test.results){
|
|
@@ -1609,10 +1622,10 @@ class DefaultReporter {
|
|
|
1609
1622
|
const shouldLog = this.config.onConsoleLog?.(log.content) ?? true;
|
|
1610
1623
|
if (!shouldLog) return;
|
|
1611
1624
|
const titles = [];
|
|
1612
|
-
const testPath =
|
|
1625
|
+
const testPath = relative(this.rootPath, log.testPath);
|
|
1613
1626
|
if (log.trace) {
|
|
1614
1627
|
const [frame] = stack_trace_parser_esm_parse(log.trace);
|
|
1615
|
-
const filePath =
|
|
1628
|
+
const filePath = relative(this.rootPath, frame.file || '');
|
|
1616
1629
|
if (filePath !== testPath) titles.push(testPath);
|
|
1617
1630
|
titles.push(`${filePath}:${frame.lineNumber}:${frame.column}`);
|
|
1618
1631
|
} else titles.push(testPath);
|
|
@@ -1625,12 +1638,13 @@ class DefaultReporter {
|
|
|
1625
1638
|
async onExit() {
|
|
1626
1639
|
this.statusRenderer?.clear();
|
|
1627
1640
|
}
|
|
1628
|
-
async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths }) {
|
|
1641
|
+
async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, unhandledErrors }) {
|
|
1629
1642
|
this.statusRenderer?.clear();
|
|
1630
1643
|
if (false === this.options.summary) return;
|
|
1631
1644
|
await printSummaryErrorLogs({
|
|
1632
1645
|
testResults,
|
|
1633
1646
|
results,
|
|
1647
|
+
unhandledErrors,
|
|
1634
1648
|
rootPath: this.rootPath,
|
|
1635
1649
|
getSourcemap,
|
|
1636
1650
|
filterRerunTestPaths
|
|
@@ -1667,7 +1681,7 @@ class GithubActionsReporter {
|
|
|
1667
1681
|
for (const test of failedTests){
|
|
1668
1682
|
const { testPath } = test;
|
|
1669
1683
|
const nameStr = getTaskNameWithPrefix(test);
|
|
1670
|
-
const shortPath =
|
|
1684
|
+
const shortPath = relative(this.rootPath, testPath);
|
|
1671
1685
|
const title = `${shortPath} > ${nameStr}`;
|
|
1672
1686
|
for (const error of test.errors || []){
|
|
1673
1687
|
let file = testPath;
|
|
@@ -2012,6 +2026,8 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
|
2012
2026
|
if (-1 === index || index === segments.length) return -1;
|
|
2013
2027
|
return index;
|
|
2014
2028
|
}
|
|
2029
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
2030
|
+
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
2015
2031
|
const hintNotDefinedError = (message)=>{
|
|
2016
2032
|
const [, varName] = message.match(/(\w+) is not defined/) || [];
|
|
2017
2033
|
if (varName) {
|
|
@@ -2103,7 +2119,7 @@ async function error_parseErrorStacktrace({ stack, getSourcemap, fullStack = isD
|
|
|
2103
2119
|
if (!source) return null;
|
|
2104
2120
|
return {
|
|
2105
2121
|
...frame,
|
|
2106
|
-
file: source,
|
|
2122
|
+
file: isRelativePath(source) ? (0, external_node_path_.resolve)(frame.file, '../', source) : new URL(source).pathname,
|
|
2107
2123
|
lineNumber: line,
|
|
2108
2124
|
name,
|
|
2109
2125
|
column
|
|
@@ -2136,7 +2152,7 @@ class JUnitReporter {
|
|
|
2136
2152
|
async createJUnitTestCase(test, getSourcemap) {
|
|
2137
2153
|
const testCase = {
|
|
2138
2154
|
name: getTaskNameWithPrefix(test),
|
|
2139
|
-
classname:
|
|
2155
|
+
classname: relative(this.rootPath, test.testPath),
|
|
2140
2156
|
time: (test.duration || 0) / 1000,
|
|
2141
2157
|
status: test.status
|
|
2142
2158
|
};
|
|
@@ -2163,7 +2179,7 @@ class JUnitReporter {
|
|
|
2163
2179
|
const skipped = testCases.filter((test)=>'skip' === test.status || 'todo' === test.status).length;
|
|
2164
2180
|
const totalTime = testCases.reduce((sum, test)=>sum + test.time, 0);
|
|
2165
2181
|
return {
|
|
2166
|
-
name:
|
|
2182
|
+
name: relative(this.rootPath, fileResult.testPath),
|
|
2167
2183
|
tests: testCases.length,
|
|
2168
2184
|
failures,
|
|
2169
2185
|
errors,
|
|
@@ -2235,7 +2251,7 @@ class JUnitReporter {
|
|
|
2235
2251
|
class VerboseReporter extends DefaultReporter {
|
|
2236
2252
|
onTestFileResult(test) {
|
|
2237
2253
|
this.statusRenderer?.onTestFileResult();
|
|
2238
|
-
const relativePath =
|
|
2254
|
+
const relativePath = relative(this.rootPath, test.testPath);
|
|
2239
2255
|
const { slowTestThreshold } = this.config;
|
|
2240
2256
|
logFileTitle(test, relativePath, true);
|
|
2241
2257
|
for (const result of test.results)logCase(result, {
|
|
@@ -2346,7 +2362,7 @@ class Rstest {
|
|
|
2346
2362
|
});
|
|
2347
2363
|
this.reporters = reporters;
|
|
2348
2364
|
this.snapshotManager = snapshotManager;
|
|
2349
|
-
this.version = "0.7.
|
|
2365
|
+
this.version = "0.7.4";
|
|
2350
2366
|
this.rootPath = rootPath;
|
|
2351
2367
|
this.originalConfig = userConfig;
|
|
2352
2368
|
this.normalizedConfig = rstestConfig;
|
|
@@ -2366,6 +2382,7 @@ class Rstest {
|
|
|
2366
2382
|
configFilePath: project.configFilePath,
|
|
2367
2383
|
rootPath: config.root,
|
|
2368
2384
|
name: config.name,
|
|
2385
|
+
_globalSetups: false,
|
|
2369
2386
|
outputModule: config.output?.module ?? 'true' === process.env.RSTEST_OUTPUT_MODULE,
|
|
2370
2387
|
environmentName: formatEnvironmentName(config.name),
|
|
2371
2388
|
normalizedConfig: config
|
|
@@ -2374,6 +2391,7 @@ class Rstest {
|
|
|
2374
2391
|
{
|
|
2375
2392
|
configFilePath,
|
|
2376
2393
|
rootPath,
|
|
2394
|
+
_globalSetups: false,
|
|
2377
2395
|
name: rstestConfig.name,
|
|
2378
2396
|
outputModule: rstestConfig.output?.module ?? 'true' === process.env.RSTEST_OUTPUT_MODULE,
|
|
2379
2397
|
environmentName: formatEnvironmentName(rstestConfig.name),
|
|
@@ -2489,4 +2507,4 @@ function defineConfig(config) {
|
|
|
2489
2507
|
function defineProject(config) {
|
|
2490
2508
|
return config;
|
|
2491
2509
|
}
|
|
2492
|
-
export { EventEmitter, afterAll, afterEach, assert, beforeAll, beforeEach, config_loadConfig as loadConfig, core_createRstest as createRstest, core_logger, createRsbuild, defineConfig, defineProject, describe, error_printError, expect, init_initCli as initCli, it, mergeRstestConfig, onTestFailed, onTestFinished, public_rstest as rstest, public_test as test, rs, runCLI, runRest };
|
|
2510
|
+
export { EventEmitter, afterAll, afterEach, assert, beforeAll, beforeEach, config_loadConfig as loadConfig, core_createRstest as createRstest, core_logger, createRsbuild, defineConfig, defineProject, describe, error_printError, expect, init_initCli as initCli, it, mergeProjectConfig, mergeRstestConfig, onTestFailed, onTestFinished, public_rstest as rstest, public_test as test, rs, runCLI, runRest };
|