@rstest/core 0.7.0 → 0.7.1
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~122.js +44 -20
- package/dist/0~173.js +7 -2
- package/dist/0~346.js +46 -0
- package/dist/0~835.js +143 -0
- package/dist/0~923.js +149 -0
- package/dist/155.js +5 -3
- package/dist/362.js +18 -185
- package/dist/index.d.ts +3 -1
- package/dist/worker.d.ts +4 -1
- package/package.json +1 -1
package/dist/0~122.js
CHANGED
|
@@ -202,6 +202,7 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
202
202
|
options: {
|
|
203
203
|
entryInfo,
|
|
204
204
|
context: {
|
|
205
|
+
outputModule: project.outputModule,
|
|
205
206
|
taskId: index + 1,
|
|
206
207
|
project: projectName,
|
|
207
208
|
rootPath: context.rootPath,
|
|
@@ -273,6 +274,7 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
273
274
|
context: {
|
|
274
275
|
taskId: index + 1,
|
|
275
276
|
project: projectName,
|
|
277
|
+
outputModule: project.outputModule,
|
|
276
278
|
rootPath: context.rootPath,
|
|
277
279
|
projectRoot: project.rootPath,
|
|
278
280
|
runtimeConfig: serializableConfig(runtimeConfig)
|
|
@@ -302,11 +304,15 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
302
304
|
};
|
|
303
305
|
};
|
|
304
306
|
const RUNTIME_CHUNK_NAME = 'runtime';
|
|
307
|
+
const requireShim = `// Rstest ESM shims
|
|
308
|
+
import __rstest_shim_module__ from 'node:module';
|
|
309
|
+
const require = /*#__PURE__*/ __rstest_shim_module__.createRequire(import.meta.url);
|
|
310
|
+
`;
|
|
305
311
|
const pluginBasic = (context)=>({
|
|
306
312
|
name: 'rstest:basic',
|
|
307
313
|
setup: (api)=>{
|
|
308
314
|
api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig, name })=>{
|
|
309
|
-
const { normalizedConfig: { resolve, source, output, tools, performance, dev, testEnvironment }, rootPath } = context.projects.find((p)=>p.environmentName === name);
|
|
315
|
+
const { normalizedConfig: { resolve, source, output, tools, performance, dev, testEnvironment }, outputModule, rootPath } = context.projects.find((p)=>p.environmentName === name);
|
|
310
316
|
return mergeEnvironmentConfig(config, {
|
|
311
317
|
performance,
|
|
312
318
|
tools,
|
|
@@ -326,6 +332,10 @@ const pluginBasic = (context)=>({
|
|
|
326
332
|
sourceMap: {
|
|
327
333
|
js: 'source-map'
|
|
328
334
|
},
|
|
335
|
+
module: outputModule,
|
|
336
|
+
filename: outputModule ? {
|
|
337
|
+
js: '[name].mjs'
|
|
338
|
+
} : void 0,
|
|
329
339
|
distPath: {
|
|
330
340
|
root: context.projects.length > 1 ? `${TEMP_RSTEST_OUTPUT_DIR}/${name}` : TEMP_RSTEST_OUTPUT_DIR
|
|
331
341
|
}
|
|
@@ -336,7 +346,7 @@ const pluginBasic = (context)=>({
|
|
|
336
346
|
config.mode = isProd ? 'production' : 'development';
|
|
337
347
|
config.output ??= {};
|
|
338
348
|
config.output.iife = false;
|
|
339
|
-
config.output.importFunctionName = '__rstest_dynamic_import__';
|
|
349
|
+
config.output.importFunctionName = outputModule ? 'import.meta.__rstest_dynamic_import__' : '__rstest_dynamic_import__';
|
|
340
350
|
config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
|
|
341
351
|
if (!config.devtool || !config.devtool.includes('inline')) config.devtool = 'nosources-source-map';
|
|
342
352
|
config.plugins.push(new rspack.experiments.RstestPlugin({
|
|
@@ -345,6 +355,12 @@ const pluginBasic = (context)=>({
|
|
|
345
355
|
hoistMockModule: true,
|
|
346
356
|
manualMockRoot: posix.resolve(rootPath, '__mocks__')
|
|
347
357
|
}));
|
|
358
|
+
if (outputModule) config.plugins.push(new rspack.BannerPlugin({
|
|
359
|
+
banner: requireShim,
|
|
360
|
+
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
|
|
361
|
+
raw: true,
|
|
362
|
+
include: /\.(js|mjs)$/
|
|
363
|
+
}));
|
|
348
364
|
config.module.parser ??= {};
|
|
349
365
|
config.module.parser.javascript = {
|
|
350
366
|
importDynamic: false,
|
|
@@ -467,20 +483,20 @@ const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context
|
|
|
467
483
|
});
|
|
468
484
|
}
|
|
469
485
|
});
|
|
470
|
-
const autoExternalNodeModules = ({ context, request, dependencyType, getResolve }, callback)=>{
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
486
|
+
const autoExternalNodeModules = (outputModule)=>({ context, request, dependencyType, getResolve }, callback)=>{
|
|
487
|
+
if (!request) return callback();
|
|
488
|
+
if (request.startsWith('@swc/helpers/') || request.endsWith('.wasm')) return callback();
|
|
489
|
+
const doExternal = (externalPath = request)=>{
|
|
490
|
+
callback(void 0, externalPath, 'commonjs' === dependencyType ? 'commonjs' : outputModule ? 'module-import' : 'import');
|
|
491
|
+
};
|
|
492
|
+
const resolver = getResolve?.();
|
|
493
|
+
if (!resolver) return callback();
|
|
494
|
+
resolver(context, request, (err, resolvePath)=>{
|
|
495
|
+
if (err) return callback(void 0, request, 'node-commonjs');
|
|
496
|
+
if (resolvePath && resolvePath.includes('node_modules') && !/\.(?:ts|tsx|jsx|mts|cts)$/.test(resolvePath)) return doExternal(resolvePath);
|
|
497
|
+
return callback();
|
|
498
|
+
});
|
|
475
499
|
};
|
|
476
|
-
const resolver = getResolve?.();
|
|
477
|
-
if (!resolver) return callback();
|
|
478
|
-
resolver(context, request, (err, resolvePath)=>{
|
|
479
|
-
if (err) return callback();
|
|
480
|
-
if (resolvePath && resolvePath.includes('node_modules') && !/\.(?:ts|tsx|jsx|mts|cts)$/.test(resolvePath)) return doExternal(resolvePath);
|
|
481
|
-
return callback();
|
|
482
|
-
});
|
|
483
|
-
};
|
|
484
500
|
function autoExternalNodeBuiltin({ request, dependencyType }, callback) {
|
|
485
501
|
if (!request) return void callback();
|
|
486
502
|
const isNodeBuiltin = isBuiltin(request) || ADDITIONAL_NODE_BUILTINS.some((builtin)=>{
|
|
@@ -494,11 +510,11 @@ const pluginExternal = (context)=>({
|
|
|
494
510
|
name: 'rstest:external',
|
|
495
511
|
setup: (api)=>{
|
|
496
512
|
api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig, name })=>{
|
|
497
|
-
const { normalizedConfig: { testEnvironment } } = context.projects.find((p)=>p.environmentName === name);
|
|
513
|
+
const { normalizedConfig: { testEnvironment }, outputModule } = context.projects.find((p)=>p.environmentName === name);
|
|
498
514
|
return mergeEnvironmentConfig(config, {
|
|
499
515
|
output: {
|
|
500
516
|
externals: 'node' === testEnvironment ? [
|
|
501
|
-
autoExternalNodeModules
|
|
517
|
+
autoExternalNodeModules(outputModule)
|
|
502
518
|
] : void 0
|
|
503
519
|
},
|
|
504
520
|
tools: {
|
|
@@ -509,7 +525,7 @@ const pluginExternal = (context)=>({
|
|
|
509
525
|
});
|
|
510
526
|
config.externalsPresets ??= {};
|
|
511
527
|
config.externalsPresets.node = false;
|
|
512
|
-
config.externals.
|
|
528
|
+
config.externals.unshift(autoExternalNodeBuiltin);
|
|
513
529
|
}
|
|
514
530
|
}
|
|
515
531
|
});
|
|
@@ -553,6 +569,10 @@ const pluginInspect = ()=>enable ? {
|
|
|
553
569
|
const external_node_fs_ = __webpack_require__("node:fs");
|
|
554
570
|
const mockRuntime_dirname = external_node_path_["default"].dirname(fileURLToPath(import.meta.url));
|
|
555
571
|
class MockRuntimeRspackPlugin {
|
|
572
|
+
outputModule;
|
|
573
|
+
constructor(outputModule){
|
|
574
|
+
this.outputModule = outputModule;
|
|
575
|
+
}
|
|
556
576
|
apply(compiler) {
|
|
557
577
|
const { RuntimeModule } = compiler.webpack;
|
|
558
578
|
class RetestImportRuntimeModule extends RuntimeModule {
|
|
@@ -570,12 +590,16 @@ class MockRuntimeRspackPlugin {
|
|
|
570
590
|
const finalSource = module.source.source.toString('utf-8').replace('for (var moduleId in moreModules) {', "for (var moduleId in moreModules) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId)) continue;");
|
|
571
591
|
module.source.source = Buffer.from(finalSource);
|
|
572
592
|
}
|
|
593
|
+
if ('module_chunk_loading' === module.name) {
|
|
594
|
+
const finalSource = module.source.source.toString('utf-8').replace('for (moduleId in __webpack_modules__) {', "for (moduleId in __webpack_modules__) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId)) continue;");
|
|
595
|
+
module.source.source = Buffer.from(finalSource);
|
|
596
|
+
}
|
|
573
597
|
if ('define_property_getters' === module.name) {
|
|
574
598
|
const finalSource = module.source.source.toString('utf-8').replace('enumerable: true, get:', 'enumerable: true, configurable: true, get:');
|
|
575
599
|
module.source.source = Buffer.from(finalSource);
|
|
576
600
|
}
|
|
577
601
|
if ('async_wasm_loading' === module.name) {
|
|
578
|
-
const finalSource = module.source.source.toString('utf-8').replace('readFile(', 'readWasmFile(');
|
|
602
|
+
const finalSource = module.source.source.toString('utf-8').replace('readFile(', this.outputModule ? 'import.meta.readWasmFile(' : 'readWasmFile(');
|
|
579
603
|
module.source.source = Buffer.from(finalSource);
|
|
580
604
|
}
|
|
581
605
|
});
|
|
@@ -591,7 +615,7 @@ const pluginMockRuntime = {
|
|
|
591
615
|
name: 'rstest:mock-runtime',
|
|
592
616
|
setup: (api)=>{
|
|
593
617
|
api.modifyRspackConfig(async (config)=>{
|
|
594
|
-
config.plugins.push(new MockRuntimeRspackPlugin());
|
|
618
|
+
config.plugins.push(new MockRuntimeRspackPlugin(Boolean(config.output.module)));
|
|
595
619
|
});
|
|
596
620
|
}
|
|
597
621
|
};
|
package/dist/0~173.js
CHANGED
|
@@ -379,12 +379,17 @@ async function runTests(context) {
|
|
|
379
379
|
afterTestsWatchRun();
|
|
380
380
|
});
|
|
381
381
|
} else {
|
|
382
|
+
let isTeardown = false;
|
|
382
383
|
const unExpectedExit = (code)=>{
|
|
383
|
-
src_logger.log(picocolors_default().
|
|
384
|
-
|
|
384
|
+
if (isTeardown) src_logger.log(picocolors_default().yellow(`Rstest exited unexpectedly with code ${code}, this is likely caused by test environment teardown.`));
|
|
385
|
+
else {
|
|
386
|
+
src_logger.log(picocolors_default().red(`Rstest exited unexpectedly with code ${code}, terminating test run.`));
|
|
387
|
+
process.exitCode = 1;
|
|
388
|
+
}
|
|
385
389
|
};
|
|
386
390
|
process.on('exit', unExpectedExit);
|
|
387
391
|
await run();
|
|
392
|
+
isTeardown = true;
|
|
388
393
|
await pool.close();
|
|
389
394
|
await closeServer();
|
|
390
395
|
process.off('exit', unExpectedExit);
|
package/dist/0~346.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import node_vm from "node:vm";
|
|
4
|
+
const shouldInterop = ({ interopDefault = true, modulePath, mod })=>{
|
|
5
|
+
if (!interopDefault) return false;
|
|
6
|
+
return !modulePath.endsWith('.mjs') && 'default' in mod;
|
|
7
|
+
};
|
|
8
|
+
const isPrimitive = (v)=>v !== Object(v);
|
|
9
|
+
function interopModule(mod) {
|
|
10
|
+
if (isPrimitive(mod)) return {
|
|
11
|
+
mod: {
|
|
12
|
+
default: mod
|
|
13
|
+
},
|
|
14
|
+
defaultExport: mod
|
|
15
|
+
};
|
|
16
|
+
const defaultExport = 'default' in mod ? mod.default : mod;
|
|
17
|
+
if (!isPrimitive(defaultExport) && '__esModule' in defaultExport) return {
|
|
18
|
+
mod: defaultExport,
|
|
19
|
+
defaultExport: 'default' in defaultExport ? defaultExport.default : defaultExport
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
mod,
|
|
23
|
+
defaultExport
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const asModule = async (something, defaultExport, context, unlinked)=>{
|
|
27
|
+
const { Module, SyntheticModule } = await import("node:vm");
|
|
28
|
+
if (something instanceof Module) return something;
|
|
29
|
+
const exports = [
|
|
30
|
+
...new Set([
|
|
31
|
+
'default',
|
|
32
|
+
...Object.keys(something)
|
|
33
|
+
])
|
|
34
|
+
];
|
|
35
|
+
const m = new SyntheticModule(exports, ()=>{
|
|
36
|
+
for (const name of exports)m.setExport(name, 'default' === name ? defaultExport : something[name]);
|
|
37
|
+
}, {
|
|
38
|
+
context
|
|
39
|
+
});
|
|
40
|
+
if (unlinked) return m;
|
|
41
|
+
await m.link(()=>{});
|
|
42
|
+
if (m.instantiate) m.instantiate();
|
|
43
|
+
await m.evaluate();
|
|
44
|
+
return m;
|
|
45
|
+
};
|
|
46
|
+
export { asModule, interopModule, node_vm, shouldInterop };
|
package/dist/0~835.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
+
import { posix, external_node_module_createRequire, src_logger } from "./946.js";
|
|
5
|
+
import { pathToFileURL } from "./770.js";
|
|
6
|
+
import { node_vm, asModule, shouldInterop, interopModule } from "./0~346.js";
|
|
7
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
8
|
+
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
9
|
+
const createRequire = (filename, distPath, rstestContext, assetFiles, interopDefault)=>{
|
|
10
|
+
const _require = (()=>{
|
|
11
|
+
try {
|
|
12
|
+
return external_node_module_createRequire(filename);
|
|
13
|
+
} catch (_err) {
|
|
14
|
+
return external_node_module_createRequire(distPath);
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
17
|
+
const require = (id)=>{
|
|
18
|
+
const currentDirectory = posix.dirname(distPath);
|
|
19
|
+
const joinedPath = isRelativePath(id) ? posix.join(currentDirectory, id) : id;
|
|
20
|
+
const content = assetFiles[joinedPath];
|
|
21
|
+
if (content) try {
|
|
22
|
+
return cacheableLoadModule({
|
|
23
|
+
codeContent: content,
|
|
24
|
+
testPath: joinedPath,
|
|
25
|
+
distPath: joinedPath,
|
|
26
|
+
rstestContext,
|
|
27
|
+
assetFiles,
|
|
28
|
+
interopDefault
|
|
29
|
+
});
|
|
30
|
+
} catch (err) {
|
|
31
|
+
src_logger.error(`load file ${joinedPath} failed:\n`, err instanceof Error ? err.message : err);
|
|
32
|
+
}
|
|
33
|
+
const resolved = _require.resolve(id);
|
|
34
|
+
return _require(resolved);
|
|
35
|
+
};
|
|
36
|
+
require.resolve = _require.resolve;
|
|
37
|
+
require.main = _require.main;
|
|
38
|
+
return require;
|
|
39
|
+
};
|
|
40
|
+
const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
|
|
41
|
+
const resolvedPath = (0, external_node_path_.isAbsolute)(specifier) ? pathToFileURL(specifier) : import.meta.resolve(specifier, pathToFileURL(testPath));
|
|
42
|
+
const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
|
|
43
|
+
if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
|
|
44
|
+
if (modulePath.endsWith('.json')) {
|
|
45
|
+
const importedModule = await import(modulePath, {
|
|
46
|
+
with: {
|
|
47
|
+
type: 'json'
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return returnModule ? asModule(importedModule.default, importedModule.default) : {
|
|
51
|
+
...importedModule.default,
|
|
52
|
+
default: importedModule.default
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const importedModule = await import(modulePath, importAttributes);
|
|
56
|
+
if (shouldInterop({
|
|
57
|
+
interopDefault,
|
|
58
|
+
modulePath,
|
|
59
|
+
mod: importedModule
|
|
60
|
+
})) {
|
|
61
|
+
const { mod, defaultExport } = interopModule(importedModule);
|
|
62
|
+
if (returnModule) return asModule(mod, defaultExport);
|
|
63
|
+
return new Proxy(mod, {
|
|
64
|
+
get (mod, prop) {
|
|
65
|
+
if ('default' === prop) return defaultExport;
|
|
66
|
+
return mod[prop] ?? defaultExport?.[prop];
|
|
67
|
+
},
|
|
68
|
+
has (mod, prop) {
|
|
69
|
+
if ('default' === prop) return void 0 !== defaultExport;
|
|
70
|
+
return prop in mod || defaultExport && prop in defaultExport;
|
|
71
|
+
},
|
|
72
|
+
getOwnPropertyDescriptor (mod, prop) {
|
|
73
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
|
|
74
|
+
if (descriptor) return descriptor;
|
|
75
|
+
if ('default' === prop && void 0 !== defaultExport) return {
|
|
76
|
+
value: defaultExport,
|
|
77
|
+
enumerable: true,
|
|
78
|
+
configurable: true
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return importedModule;
|
|
84
|
+
};
|
|
85
|
+
const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles, interopDefault })=>{
|
|
86
|
+
const fileDir = posix.dirname(testPath);
|
|
87
|
+
const localModule = {
|
|
88
|
+
children: [],
|
|
89
|
+
exports: {},
|
|
90
|
+
filename: testPath,
|
|
91
|
+
id: testPath,
|
|
92
|
+
isPreloading: false,
|
|
93
|
+
loaded: false,
|
|
94
|
+
path: fileDir
|
|
95
|
+
};
|
|
96
|
+
const context = {
|
|
97
|
+
module: localModule,
|
|
98
|
+
exports: localModule.exports,
|
|
99
|
+
require: createRequire(testPath, distPath, rstestContext, assetFiles, interopDefault),
|
|
100
|
+
readWasmFile: (wasmPath, callback)=>{
|
|
101
|
+
const joinedPath = isRelativePath(wasmPath) ? posix.join(posix.dirname(distPath), wasmPath) : wasmPath;
|
|
102
|
+
const content = assetFiles[posix.normalize(joinedPath)];
|
|
103
|
+
if (content) callback(null, Buffer.from(content, 'base64'));
|
|
104
|
+
else callback(new Error(`WASM file ${joinedPath} not found in asset files.`));
|
|
105
|
+
},
|
|
106
|
+
__rstest_dynamic_import__: defineRstestDynamicImport({
|
|
107
|
+
testPath,
|
|
108
|
+
interopDefault
|
|
109
|
+
}),
|
|
110
|
+
__dirname: fileDir,
|
|
111
|
+
__filename: testPath,
|
|
112
|
+
...rstestContext
|
|
113
|
+
};
|
|
114
|
+
const codeDefinition = `'use strict';(${Object.keys(context).join(',')})=>{`;
|
|
115
|
+
const code = `${codeDefinition}${codeContent}\n}`;
|
|
116
|
+
const fn = node_vm.runInThisContext(code, {
|
|
117
|
+
filename: distPath,
|
|
118
|
+
lineOffset: 0,
|
|
119
|
+
columnOffset: -codeDefinition.length,
|
|
120
|
+
importModuleDynamically: (specifier, _referencer, importAttributes)=>defineRstestDynamicImport({
|
|
121
|
+
testPath,
|
|
122
|
+
interopDefault,
|
|
123
|
+
returnModule: true
|
|
124
|
+
})(specifier, importAttributes)
|
|
125
|
+
});
|
|
126
|
+
fn(...Object.values(context));
|
|
127
|
+
return localModule.exports;
|
|
128
|
+
};
|
|
129
|
+
const moduleCache = new Map();
|
|
130
|
+
const cacheableLoadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles, interopDefault })=>{
|
|
131
|
+
if (moduleCache.has(testPath)) return moduleCache.get(testPath);
|
|
132
|
+
const mod = loadModule({
|
|
133
|
+
codeContent,
|
|
134
|
+
distPath,
|
|
135
|
+
testPath,
|
|
136
|
+
rstestContext,
|
|
137
|
+
assetFiles,
|
|
138
|
+
interopDefault
|
|
139
|
+
});
|
|
140
|
+
moduleCache.set(testPath, mod);
|
|
141
|
+
return mod;
|
|
142
|
+
};
|
|
143
|
+
export { cacheableLoadModule, loadModule };
|
package/dist/0~923.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
+
import { posix, src_logger } from "./946.js";
|
|
5
|
+
import { pathToFileURL } from "./770.js";
|
|
6
|
+
import { node_vm, interopModule, shouldInterop } from "./0~346.js";
|
|
7
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
8
|
+
var loadEsModule_EsmMode = /*#__PURE__*/ function(EsmMode) {
|
|
9
|
+
EsmMode[EsmMode["Unknown"] = 0] = "Unknown";
|
|
10
|
+
EsmMode[EsmMode["Evaluated"] = 1] = "Evaluated";
|
|
11
|
+
EsmMode[EsmMode["Unlinked"] = 2] = "Unlinked";
|
|
12
|
+
return EsmMode;
|
|
13
|
+
}({});
|
|
14
|
+
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
15
|
+
const defineRstestDynamicImport = ({ distPath, testPath, assetFiles, interopDefault, returnModule, esmMode })=>async (specifier, importAttributes)=>{
|
|
16
|
+
const currentDirectory = posix.dirname(distPath);
|
|
17
|
+
const joinedPath = isRelativePath(specifier) ? posix.join(currentDirectory, specifier) : specifier;
|
|
18
|
+
const content = assetFiles[joinedPath];
|
|
19
|
+
if (content) try {
|
|
20
|
+
return await loadModule({
|
|
21
|
+
codeContent: content,
|
|
22
|
+
testPath,
|
|
23
|
+
distPath: joinedPath,
|
|
24
|
+
rstestContext: {},
|
|
25
|
+
assetFiles,
|
|
26
|
+
interopDefault,
|
|
27
|
+
esmMode
|
|
28
|
+
});
|
|
29
|
+
} catch (err) {
|
|
30
|
+
src_logger.error(`load file ${joinedPath} failed:\n`, err instanceof Error ? err.message : err);
|
|
31
|
+
}
|
|
32
|
+
const resolvedPath = (0, external_node_path_.isAbsolute)(specifier) ? pathToFileURL(specifier) : import.meta.resolve(specifier, pathToFileURL(testPath));
|
|
33
|
+
const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
|
|
34
|
+
if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
|
|
35
|
+
if (modulePath.endsWith('.json')) {
|
|
36
|
+
const importedModule = await import(modulePath, {
|
|
37
|
+
with: {
|
|
38
|
+
type: 'json'
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return returnModule ? asModule(importedModule.default) : {
|
|
42
|
+
...importedModule.default,
|
|
43
|
+
default: importedModule.default
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const importedModule = await import(modulePath, importAttributes);
|
|
47
|
+
if (shouldInterop({
|
|
48
|
+
interopDefault,
|
|
49
|
+
modulePath,
|
|
50
|
+
mod: importedModule
|
|
51
|
+
}) && !modulePath.startsWith('node:')) {
|
|
52
|
+
const { mod, defaultExport } = interopModule(importedModule);
|
|
53
|
+
if (returnModule) return asModule(mod);
|
|
54
|
+
return new Proxy(mod, {
|
|
55
|
+
get (mod, prop) {
|
|
56
|
+
if ('default' === prop) return defaultExport;
|
|
57
|
+
return mod[prop] ?? defaultExport?.[prop];
|
|
58
|
+
},
|
|
59
|
+
has (mod, prop) {
|
|
60
|
+
if ('default' === prop) return void 0 !== defaultExport;
|
|
61
|
+
return prop in mod || defaultExport && prop in defaultExport;
|
|
62
|
+
},
|
|
63
|
+
getOwnPropertyDescriptor (mod, prop) {
|
|
64
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
|
|
65
|
+
if (descriptor) return descriptor;
|
|
66
|
+
if ('default' === prop && void 0 !== defaultExport) return {
|
|
67
|
+
value: defaultExport,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return importedModule;
|
|
75
|
+
};
|
|
76
|
+
const asModule = async (something, context, unlinked)=>{
|
|
77
|
+
const { Module, SyntheticModule } = await import("node:vm");
|
|
78
|
+
if (something instanceof Module) return something;
|
|
79
|
+
const exports = [
|
|
80
|
+
...new Set([
|
|
81
|
+
'default',
|
|
82
|
+
...Object.keys(something)
|
|
83
|
+
])
|
|
84
|
+
];
|
|
85
|
+
const syntheticModule = new SyntheticModule(exports, ()=>{
|
|
86
|
+
for (const name of exports)syntheticModule.setExport(name, 'default' === name ? something[name] ?? something : something[name]);
|
|
87
|
+
}, {
|
|
88
|
+
context
|
|
89
|
+
});
|
|
90
|
+
if (unlinked) return syntheticModule;
|
|
91
|
+
await syntheticModule.link(()=>{});
|
|
92
|
+
await syntheticModule.evaluate();
|
|
93
|
+
return syntheticModule;
|
|
94
|
+
};
|
|
95
|
+
const esmCache = new Map();
|
|
96
|
+
const loadModule = async ({ codeContent, distPath, testPath, assetFiles, interopDefault, esmMode = 0 })=>{
|
|
97
|
+
const code = codeContent;
|
|
98
|
+
let esm = esmCache.get(distPath);
|
|
99
|
+
if (!esm) {
|
|
100
|
+
esm = new node_vm.SourceTextModule(code, {
|
|
101
|
+
identifier: distPath,
|
|
102
|
+
lineOffset: 0,
|
|
103
|
+
columnOffset: 0,
|
|
104
|
+
initializeImportMeta: (meta)=>{
|
|
105
|
+
meta.url = pathToFileURL(distPath.endsWith('rstest-runtime.mjs') ? distPath : testPath).toString();
|
|
106
|
+
meta.__rstest_dynamic_import__ = defineRstestDynamicImport({
|
|
107
|
+
assetFiles,
|
|
108
|
+
testPath,
|
|
109
|
+
distPath: distPath || testPath,
|
|
110
|
+
interopDefault,
|
|
111
|
+
returnModule: false,
|
|
112
|
+
esmMode: 0
|
|
113
|
+
});
|
|
114
|
+
meta.readWasmFile = (wasmPath, callback)=>{
|
|
115
|
+
const joinedPath = isRelativePath(wasmPath.pathname) ? posix.join(posix.dirname(distPath), wasmPath.pathname) : wasmPath.pathname;
|
|
116
|
+
const content = assetFiles[posix.normalize(joinedPath)];
|
|
117
|
+
if (content) callback(null, Buffer.from(content, 'base64'));
|
|
118
|
+
else callback(new Error(`WASM file ${joinedPath} not found in asset files.`));
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
importModuleDynamically: (specifier, _referencer, importAttributes)=>defineRstestDynamicImport({
|
|
122
|
+
assetFiles,
|
|
123
|
+
testPath,
|
|
124
|
+
distPath: distPath || testPath,
|
|
125
|
+
interopDefault,
|
|
126
|
+
returnModule: true,
|
|
127
|
+
esmMode: 2
|
|
128
|
+
})(specifier, importAttributes)
|
|
129
|
+
});
|
|
130
|
+
distPath && esmCache.set(distPath, esm);
|
|
131
|
+
}
|
|
132
|
+
if (2 === esmMode) return esm;
|
|
133
|
+
if ('unlinked' === esm.status) await esm.link(async (specifier, referencingModule)=>{
|
|
134
|
+
const result = await defineRstestDynamicImport({
|
|
135
|
+
assetFiles,
|
|
136
|
+
testPath,
|
|
137
|
+
distPath: distPath || testPath,
|
|
138
|
+
interopDefault,
|
|
139
|
+
returnModule: true,
|
|
140
|
+
esmMode: 2
|
|
141
|
+
})(specifier, referencingModule);
|
|
142
|
+
const linkedModule = await asModule(result, referencingModule.context, true);
|
|
143
|
+
return linkedModule;
|
|
144
|
+
});
|
|
145
|
+
'evaluated' !== esm.status && 'evaluating' !== esm.status && await esm.evaluate();
|
|
146
|
+
const ns = esm.namespace;
|
|
147
|
+
return ns.default && ns.default instanceof Promise ? ns.default : ns;
|
|
148
|
+
};
|
|
149
|
+
export { asModule, loadEsModule_EsmMode, loadModule };
|
package/dist/155.js
CHANGED
|
@@ -500,7 +500,7 @@ function prepareCli() {
|
|
|
500
500
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
501
501
|
}
|
|
502
502
|
function showRstest() {
|
|
503
|
-
src_logger.greet(" Rstest v0.7.
|
|
503
|
+
src_logger.greet(" Rstest v0.7.1");
|
|
504
504
|
src_logger.log('');
|
|
505
505
|
}
|
|
506
506
|
const applyCommonOptions = (cli)=>{
|
|
@@ -544,7 +544,7 @@ const runRest = async ({ options, filters, command })=>{
|
|
|
544
544
|
function setupCommands() {
|
|
545
545
|
const cli = dist('rstest');
|
|
546
546
|
cli.help();
|
|
547
|
-
cli.version("0.7.
|
|
547
|
+
cli.version("0.7.1");
|
|
548
548
|
applyCommonOptions(cli);
|
|
549
549
|
cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
550
550
|
showRstest();
|
|
@@ -2428,7 +2428,7 @@ class Rstest {
|
|
|
2428
2428
|
});
|
|
2429
2429
|
this.reporters = reporters;
|
|
2430
2430
|
this.snapshotManager = snapshotManager;
|
|
2431
|
-
this.version = "0.7.
|
|
2431
|
+
this.version = "0.7.1";
|
|
2432
2432
|
this.rootPath = rootPath;
|
|
2433
2433
|
this.originalConfig = userConfig;
|
|
2434
2434
|
this.normalizedConfig = rstestConfig;
|
|
@@ -2448,6 +2448,7 @@ class Rstest {
|
|
|
2448
2448
|
configFilePath: project.configFilePath,
|
|
2449
2449
|
rootPath: config.root,
|
|
2450
2450
|
name: config.name,
|
|
2451
|
+
outputModule: config.output?.module ?? 'true' === process.env.RSTEST_OUTPUT_MODULE,
|
|
2451
2452
|
environmentName: formatEnvironmentName(config.name),
|
|
2452
2453
|
normalizedConfig: config
|
|
2453
2454
|
};
|
|
@@ -2456,6 +2457,7 @@ class Rstest {
|
|
|
2456
2457
|
configFilePath,
|
|
2457
2458
|
rootPath,
|
|
2458
2459
|
name: rstestConfig.name,
|
|
2460
|
+
outputModule: rstestConfig.output?.module ?? 'true' === process.env.RSTEST_OUTPUT_MODULE,
|
|
2459
2461
|
environmentName: formatEnvironmentName(rstestConfig.name),
|
|
2460
2462
|
normalizedConfig: rstestConfig
|
|
2461
2463
|
}
|
package/dist/362.js
CHANGED
|
@@ -3,9 +3,8 @@ import __rslib_shim_module__ from 'module';
|
|
|
3
3
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
4
4
|
"use strict";
|
|
5
5
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { node_v8, pathToFileURL, createBirpc } from "./770.js";
|
|
6
|
+
import { basename, globalApis, dirname, external_node_module_createRequire, resolve as pathe_M_eThtNZ_resolve, undoSerializableConfig, isAbsolute, join } from "./946.js";
|
|
7
|
+
import { node_v8, createBirpc } from "./770.js";
|
|
9
8
|
import { createCoverageProvider } from "./734.js";
|
|
10
9
|
__webpack_require__.add({
|
|
11
10
|
"../../node_modules/.pnpm/@jest+diff-sequences@30.0.1/node_modules/@jest/diff-sequences/build/index.js": function(module) {
|
|
@@ -6711,184 +6710,6 @@ function checkPkgInstalled(name) {
|
|
|
6711
6710
|
throw error;
|
|
6712
6711
|
}
|
|
6713
6712
|
}
|
|
6714
|
-
const shouldInterop = ({ interopDefault = true, modulePath, mod })=>{
|
|
6715
|
-
if (!interopDefault) return false;
|
|
6716
|
-
return !modulePath.endsWith('.mjs') && 'default' in mod;
|
|
6717
|
-
};
|
|
6718
|
-
const isPrimitive = (v)=>v !== Object(v);
|
|
6719
|
-
function interopModule(mod) {
|
|
6720
|
-
if (isPrimitive(mod)) return {
|
|
6721
|
-
mod: {
|
|
6722
|
-
default: mod
|
|
6723
|
-
},
|
|
6724
|
-
defaultExport: mod
|
|
6725
|
-
};
|
|
6726
|
-
const defaultExport = 'default' in mod ? mod.default : mod;
|
|
6727
|
-
if (!isPrimitive(defaultExport) && '__esModule' in defaultExport) return {
|
|
6728
|
-
mod: defaultExport,
|
|
6729
|
-
defaultExport: 'default' in defaultExport ? defaultExport.default : defaultExport
|
|
6730
|
-
};
|
|
6731
|
-
return {
|
|
6732
|
-
mod,
|
|
6733
|
-
defaultExport
|
|
6734
|
-
};
|
|
6735
|
-
}
|
|
6736
|
-
const asModule = async (something, defaultExport, context, unlinked)=>{
|
|
6737
|
-
const { Module, SyntheticModule } = await import("node:vm");
|
|
6738
|
-
if (something instanceof Module) return something;
|
|
6739
|
-
const exports = [
|
|
6740
|
-
...new Set([
|
|
6741
|
-
'default',
|
|
6742
|
-
...Object.keys(something)
|
|
6743
|
-
])
|
|
6744
|
-
];
|
|
6745
|
-
const m = new SyntheticModule(exports, ()=>{
|
|
6746
|
-
for (const name of exports)m.setExport(name, 'default' === name ? defaultExport : something[name]);
|
|
6747
|
-
}, {
|
|
6748
|
-
context
|
|
6749
|
-
});
|
|
6750
|
-
if (unlinked) return m;
|
|
6751
|
-
await m.link(()=>{});
|
|
6752
|
-
if (m.instantiate) m.instantiate();
|
|
6753
|
-
await m.evaluate();
|
|
6754
|
-
return m;
|
|
6755
|
-
};
|
|
6756
|
-
const external_node_path_ = __webpack_require__("node:path");
|
|
6757
|
-
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
6758
|
-
const createRequire = (filename, distPath, rstestContext, assetFiles, interopDefault)=>{
|
|
6759
|
-
const _require = (()=>{
|
|
6760
|
-
try {
|
|
6761
|
-
return external_node_module_createRequire(filename);
|
|
6762
|
-
} catch (_err) {
|
|
6763
|
-
return external_node_module_createRequire(distPath);
|
|
6764
|
-
}
|
|
6765
|
-
})();
|
|
6766
|
-
const require = (id)=>{
|
|
6767
|
-
const currentDirectory = posix.dirname(distPath);
|
|
6768
|
-
const joinedPath = isRelativePath(id) ? posix.join(currentDirectory, id) : id;
|
|
6769
|
-
const content = assetFiles[joinedPath];
|
|
6770
|
-
if (content) try {
|
|
6771
|
-
return cacheableLoadModule({
|
|
6772
|
-
codeContent: content,
|
|
6773
|
-
testPath: joinedPath,
|
|
6774
|
-
distPath: joinedPath,
|
|
6775
|
-
rstestContext,
|
|
6776
|
-
assetFiles,
|
|
6777
|
-
interopDefault
|
|
6778
|
-
});
|
|
6779
|
-
} catch (err) {
|
|
6780
|
-
src_logger.error(`load file ${joinedPath} failed:\n`, err instanceof Error ? err.message : err);
|
|
6781
|
-
}
|
|
6782
|
-
const resolved = _require.resolve(id);
|
|
6783
|
-
return _require(resolved);
|
|
6784
|
-
};
|
|
6785
|
-
require.resolve = _require.resolve;
|
|
6786
|
-
require.main = _require.main;
|
|
6787
|
-
return require;
|
|
6788
|
-
};
|
|
6789
|
-
const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
|
|
6790
|
-
const resolvedPath = (0, external_node_path_.isAbsolute)(specifier) ? pathToFileURL(specifier) : import.meta.resolve(specifier, pathToFileURL(testPath));
|
|
6791
|
-
const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
|
|
6792
|
-
if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
|
|
6793
|
-
if (modulePath.endsWith('.json')) {
|
|
6794
|
-
const importedModule = await import(modulePath, {
|
|
6795
|
-
with: {
|
|
6796
|
-
type: 'json'
|
|
6797
|
-
}
|
|
6798
|
-
});
|
|
6799
|
-
return returnModule ? asModule(importedModule.default, importedModule.default) : {
|
|
6800
|
-
...importedModule.default,
|
|
6801
|
-
default: importedModule.default
|
|
6802
|
-
};
|
|
6803
|
-
}
|
|
6804
|
-
const importedModule = await import(modulePath, importAttributes);
|
|
6805
|
-
if (shouldInterop({
|
|
6806
|
-
interopDefault,
|
|
6807
|
-
modulePath,
|
|
6808
|
-
mod: importedModule
|
|
6809
|
-
})) {
|
|
6810
|
-
const { mod, defaultExport } = interopModule(importedModule);
|
|
6811
|
-
if (returnModule) return asModule(mod, defaultExport);
|
|
6812
|
-
return new Proxy(mod, {
|
|
6813
|
-
get (mod, prop) {
|
|
6814
|
-
if ('default' === prop) return defaultExport;
|
|
6815
|
-
return mod[prop] ?? defaultExport?.[prop];
|
|
6816
|
-
},
|
|
6817
|
-
has (mod, prop) {
|
|
6818
|
-
if ('default' === prop) return void 0 !== defaultExport;
|
|
6819
|
-
return prop in mod || defaultExport && prop in defaultExport;
|
|
6820
|
-
},
|
|
6821
|
-
getOwnPropertyDescriptor (mod, prop) {
|
|
6822
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
|
|
6823
|
-
if (descriptor) return descriptor;
|
|
6824
|
-
if ('default' === prop && void 0 !== defaultExport) return {
|
|
6825
|
-
value: defaultExport,
|
|
6826
|
-
enumerable: true,
|
|
6827
|
-
configurable: true
|
|
6828
|
-
};
|
|
6829
|
-
}
|
|
6830
|
-
});
|
|
6831
|
-
}
|
|
6832
|
-
return importedModule;
|
|
6833
|
-
};
|
|
6834
|
-
const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles, interopDefault })=>{
|
|
6835
|
-
const fileDir = posix.dirname(testPath);
|
|
6836
|
-
const localModule = {
|
|
6837
|
-
children: [],
|
|
6838
|
-
exports: {},
|
|
6839
|
-
filename: testPath,
|
|
6840
|
-
id: testPath,
|
|
6841
|
-
isPreloading: false,
|
|
6842
|
-
loaded: false,
|
|
6843
|
-
path: fileDir
|
|
6844
|
-
};
|
|
6845
|
-
const context = {
|
|
6846
|
-
module: localModule,
|
|
6847
|
-
exports: localModule.exports,
|
|
6848
|
-
require: createRequire(testPath, distPath, rstestContext, assetFiles, interopDefault),
|
|
6849
|
-
readWasmFile: (wasmPath, callback)=>{
|
|
6850
|
-
const joinedPath = isRelativePath(wasmPath) ? posix.join(posix.dirname(distPath), wasmPath) : wasmPath;
|
|
6851
|
-
const content = assetFiles[posix.normalize(joinedPath)];
|
|
6852
|
-
if (content) callback(null, Buffer.from(content, 'base64'));
|
|
6853
|
-
else callback(new Error(`WASM file ${joinedPath} not found in asset files.`));
|
|
6854
|
-
},
|
|
6855
|
-
__rstest_dynamic_import__: defineRstestDynamicImport({
|
|
6856
|
-
testPath,
|
|
6857
|
-
interopDefault
|
|
6858
|
-
}),
|
|
6859
|
-
__dirname: fileDir,
|
|
6860
|
-
__filename: testPath,
|
|
6861
|
-
...rstestContext
|
|
6862
|
-
};
|
|
6863
|
-
const codeDefinition = `'use strict';(${Object.keys(context).join(',')})=>{`;
|
|
6864
|
-
const code = `${codeDefinition}${codeContent}\n}`;
|
|
6865
|
-
const fn = node_vm.runInThisContext(code, {
|
|
6866
|
-
filename: distPath,
|
|
6867
|
-
lineOffset: 0,
|
|
6868
|
-
columnOffset: -codeDefinition.length,
|
|
6869
|
-
importModuleDynamically: (specifier, _referencer, importAttributes)=>defineRstestDynamicImport({
|
|
6870
|
-
testPath,
|
|
6871
|
-
interopDefault,
|
|
6872
|
-
returnModule: true
|
|
6873
|
-
})(specifier, importAttributes)
|
|
6874
|
-
});
|
|
6875
|
-
fn(...Object.values(context));
|
|
6876
|
-
return localModule.exports;
|
|
6877
|
-
};
|
|
6878
|
-
const moduleCache = new Map();
|
|
6879
|
-
const cacheableLoadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles, interopDefault })=>{
|
|
6880
|
-
if (moduleCache.has(testPath)) return moduleCache.get(testPath);
|
|
6881
|
-
const mod = loadModule({
|
|
6882
|
-
codeContent,
|
|
6883
|
-
distPath,
|
|
6884
|
-
testPath,
|
|
6885
|
-
rstestContext,
|
|
6886
|
-
assetFiles,
|
|
6887
|
-
interopDefault
|
|
6888
|
-
});
|
|
6889
|
-
moduleCache.set(testPath, mod);
|
|
6890
|
-
return mod;
|
|
6891
|
-
};
|
|
6892
6713
|
const processSend = process.send.bind(process);
|
|
6893
6714
|
const processOn = process.on.bind(process);
|
|
6894
6715
|
const processOff = process.off.bind(process);
|
|
@@ -6993,6 +6814,8 @@ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.
|
|
|
6993
6814
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
6994
6815
|
let sourceMaps = {};
|
|
6995
6816
|
(0, source_map_support.install)({
|
|
6817
|
+
environment: 'node',
|
|
6818
|
+
handleUncaughtExceptions: false,
|
|
6996
6819
|
retrieveSourceMap: (source)=>{
|
|
6997
6820
|
if (sourceMaps[source]) return {
|
|
6998
6821
|
url: source,
|
|
@@ -7116,12 +6939,20 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot,
|
|
|
7116
6939
|
}
|
|
7117
6940
|
};
|
|
7118
6941
|
};
|
|
7119
|
-
const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault, isolate })=>{
|
|
6942
|
+
const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault, isolate, outputModule })=>{
|
|
6943
|
+
const { loadModule } = outputModule ? await import("./0~923.js").then((mod)=>({
|
|
6944
|
+
EsmMode: mod.loadEsModule_EsmMode,
|
|
6945
|
+
asModule: mod.asModule,
|
|
6946
|
+
loadModule: mod.loadModule
|
|
6947
|
+
})) : await import("./0~835.js").then((mod)=>({
|
|
6948
|
+
cacheableLoadModule: mod.cacheableLoadModule,
|
|
6949
|
+
loadModule: mod.loadModule
|
|
6950
|
+
}));
|
|
7120
6951
|
if (!isolate) await loadModule({
|
|
7121
6952
|
codeContent: `if (global && typeof global.__rstest_clean_core_cache__ === 'function') {
|
|
7122
6953
|
global.__rstest_clean_core_cache__();
|
|
7123
6954
|
}`,
|
|
7124
|
-
distPath,
|
|
6955
|
+
distPath: '',
|
|
7125
6956
|
testPath,
|
|
7126
6957
|
rstestContext,
|
|
7127
6958
|
assetFiles,
|
|
@@ -7181,7 +7012,8 @@ const runInPool = async (options)=>{
|
|
|
7181
7012
|
assetFiles,
|
|
7182
7013
|
setupEntries,
|
|
7183
7014
|
interopDefault,
|
|
7184
|
-
isolate
|
|
7015
|
+
isolate,
|
|
7016
|
+
outputModule: options.context.outputModule
|
|
7185
7017
|
});
|
|
7186
7018
|
const tests = await runner.collectTests();
|
|
7187
7019
|
return {
|
|
@@ -7225,7 +7057,8 @@ const runInPool = async (options)=>{
|
|
|
7225
7057
|
assetFiles,
|
|
7226
7058
|
setupEntries,
|
|
7227
7059
|
interopDefault,
|
|
7228
|
-
isolate
|
|
7060
|
+
isolate,
|
|
7061
|
+
outputModule: options.context.outputModule
|
|
7229
7062
|
});
|
|
7230
7063
|
const results = await runner.runTests(testPath, {
|
|
7231
7064
|
onTestCaseStart: async (test)=>{
|
package/dist/index.d.ts
CHANGED
|
@@ -2042,6 +2042,8 @@ declare type ProjectContext = {
|
|
|
2042
2042
|
environmentName: string;
|
|
2043
2043
|
/** The root path of current project. */
|
|
2044
2044
|
rootPath: string;
|
|
2045
|
+
/** Whether to output es module. */
|
|
2046
|
+
outputModule: boolean;
|
|
2045
2047
|
configFilePath?: string;
|
|
2046
2048
|
normalizedConfig: NormalizedProjectConfig;
|
|
2047
2049
|
};
|
|
@@ -2363,7 +2365,7 @@ export declare interface RstestConfig {
|
|
|
2363
2365
|
source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
|
|
2364
2366
|
performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
|
|
2365
2367
|
dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
|
|
2366
|
-
output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath'>;
|
|
2368
|
+
output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
|
|
2367
2369
|
resolve?: RsbuildConfig['resolve'];
|
|
2368
2370
|
tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
|
|
2369
2371
|
}
|
package/dist/worker.d.ts
CHANGED
|
@@ -1688,6 +1688,8 @@ declare type ProjectContext = {
|
|
|
1688
1688
|
environmentName: string;
|
|
1689
1689
|
/** The root path of current project. */
|
|
1690
1690
|
rootPath: string;
|
|
1691
|
+
/** Whether to output es module. */
|
|
1692
|
+
outputModule: boolean;
|
|
1691
1693
|
configFilePath?: string;
|
|
1692
1694
|
normalizedConfig: NormalizedProjectConfig;
|
|
1693
1695
|
};
|
|
@@ -1996,7 +1998,7 @@ declare interface RstestConfig {
|
|
|
1996
1998
|
source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
|
|
1997
1999
|
performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
|
|
1998
2000
|
dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
|
|
1999
|
-
output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath'>;
|
|
2001
|
+
output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
|
|
2000
2002
|
resolve?: RsbuildConfig['resolve'];
|
|
2001
2003
|
tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
|
|
2002
2004
|
}
|
|
@@ -2553,6 +2555,7 @@ declare type WorkerContext = {
|
|
|
2553
2555
|
project: string;
|
|
2554
2556
|
runtimeConfig: RuntimeConfig;
|
|
2555
2557
|
taskId: number;
|
|
2558
|
+
outputModule: boolean;
|
|
2556
2559
|
};
|
|
2557
2560
|
|
|
2558
2561
|
declare type XInput = {
|