@rstest/core 0.0.8 → 0.0.10
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/353.js +3 -3
- package/dist/{612.js → 562.js} +193 -124
- package/dist/cli.js +17 -29
- package/dist/worker.js +4 -4
- package/dist-types/public.d.ts +6 -4
- package/package.json +6 -6
package/dist/353.js
CHANGED
|
@@ -454,7 +454,7 @@ export const __webpack_modules__ = {
|
|
|
454
454
|
});
|
|
455
455
|
return {
|
|
456
456
|
command,
|
|
457
|
-
version: "0.0.
|
|
457
|
+
version: "0.0.10",
|
|
458
458
|
rootPath,
|
|
459
459
|
reporters,
|
|
460
460
|
snapshotManager,
|
|
@@ -469,14 +469,14 @@ export const __webpack_modules__ = {
|
|
|
469
469
|
}, config);
|
|
470
470
|
const runTests = async ()=>{
|
|
471
471
|
const { runTests } = await Promise.all([
|
|
472
|
-
__webpack_require__.e("
|
|
472
|
+
__webpack_require__.e("562"),
|
|
473
473
|
__webpack_require__.e("629")
|
|
474
474
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
|
|
475
475
|
await runTests(context, fileFilters);
|
|
476
476
|
};
|
|
477
477
|
const listTests = async (options)=>{
|
|
478
478
|
const { listTests } = await Promise.all([
|
|
479
|
-
__webpack_require__.e("
|
|
479
|
+
__webpack_require__.e("562"),
|
|
480
480
|
__webpack_require__.e("285")
|
|
481
481
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
|
|
482
482
|
await listTests(context, fileFilters, options);
|
package/dist/{612.js → 562.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
"
|
|
2
|
+
"562"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"./src/core/rsbuild.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -11,6 +11,90 @@ export const __webpack_modules__ = {
|
|
|
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");
|
|
14
|
+
const pluginBasic = (context)=>({
|
|
15
|
+
name: 'rstest:basic',
|
|
16
|
+
setup: (api)=>{
|
|
17
|
+
api.modifyRsbuildConfig(async (config)=>{
|
|
18
|
+
config.environments = {
|
|
19
|
+
[context.normalizedConfig.name]: {
|
|
20
|
+
output: {
|
|
21
|
+
target: 'node'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig })=>mergeEnvironmentConfig(config, {
|
|
27
|
+
source: {
|
|
28
|
+
define: {
|
|
29
|
+
'import.meta.rstest': "global['@rstest/core']"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
output: {
|
|
33
|
+
manifest: true,
|
|
34
|
+
sourceMap: {
|
|
35
|
+
js: 'source-map'
|
|
36
|
+
},
|
|
37
|
+
distPath: {
|
|
38
|
+
root: utils.Nk
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
tools: {
|
|
42
|
+
rspack: (config, { isProd, rspack })=>{
|
|
43
|
+
config.mode = isProd ? 'production' : 'development';
|
|
44
|
+
config.output ??= {};
|
|
45
|
+
config.output.iife = false;
|
|
46
|
+
config.output.importFunctionName = '__rstest_dynamic_import__';
|
|
47
|
+
config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
|
|
48
|
+
config.plugins.push(new rspack.experiments.RstestPlugin({
|
|
49
|
+
injectModulePathName: true,
|
|
50
|
+
importMetaPathName: true,
|
|
51
|
+
hoistMockModule: true,
|
|
52
|
+
manualMockRoot: external_pathe_["default"].resolve(context.rootPath, '__mocks__')
|
|
53
|
+
}));
|
|
54
|
+
config.module.parser ??= {};
|
|
55
|
+
config.module.parser.javascript = {
|
|
56
|
+
importDynamic: false,
|
|
57
|
+
requireDynamic: false,
|
|
58
|
+
requireAsExpression: false,
|
|
59
|
+
requireResolve: false,
|
|
60
|
+
...config.module.parser.javascript || {}
|
|
61
|
+
};
|
|
62
|
+
config.resolve ??= {};
|
|
63
|
+
config.resolve.extensions ??= [];
|
|
64
|
+
config.resolve.extensions.push('.cjs');
|
|
65
|
+
config.resolve.extensionAlias ??= {};
|
|
66
|
+
config.resolve.extensionAlias['.js'] = [
|
|
67
|
+
'.js',
|
|
68
|
+
'.ts',
|
|
69
|
+
'.tsx'
|
|
70
|
+
];
|
|
71
|
+
config.resolve.extensionAlias['.jsx'] = [
|
|
72
|
+
'.jsx',
|
|
73
|
+
'.tsx'
|
|
74
|
+
];
|
|
75
|
+
if ('node' === context.normalizedConfig.testEnvironment) config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
|
|
76
|
+
'main'
|
|
77
|
+
];
|
|
78
|
+
config.resolve.byDependency ??= {};
|
|
79
|
+
config.resolve.byDependency.commonjs ??= {};
|
|
80
|
+
config.resolve.byDependency.commonjs.mainFields = [
|
|
81
|
+
'main',
|
|
82
|
+
'...'
|
|
83
|
+
];
|
|
84
|
+
config.optimization = {
|
|
85
|
+
moduleIds: 'named',
|
|
86
|
+
chunkIds: 'named',
|
|
87
|
+
nodeEnv: false,
|
|
88
|
+
...config.optimization || {},
|
|
89
|
+
runtimeChunk: {
|
|
90
|
+
name: 'runtime'
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
});
|
|
14
98
|
var external_node_path_ = __webpack_require__("node:path");
|
|
15
99
|
var external_node_url_ = __webpack_require__("node:url");
|
|
16
100
|
const PLUGIN_CSS_FILTER = 'rstest:css-filter';
|
|
@@ -86,6 +170,52 @@ export const __webpack_modules__ = {
|
|
|
86
170
|
});
|
|
87
171
|
}
|
|
88
172
|
});
|
|
173
|
+
const autoExternalNodeModules = ({ context, request, dependencyType, getResolve }, callback)=>{
|
|
174
|
+
if (!request) return callback();
|
|
175
|
+
if (request.startsWith('@swc/helpers/')) return callback();
|
|
176
|
+
const doExternal = (externalPath = request)=>{
|
|
177
|
+
callback(void 0, externalPath, 'commonjs' === dependencyType ? 'commonjs' : 'import');
|
|
178
|
+
};
|
|
179
|
+
const resolver = getResolve?.();
|
|
180
|
+
if (!resolver) return callback();
|
|
181
|
+
resolver(context, request, (err, resolvePath)=>{
|
|
182
|
+
if (err) return callback();
|
|
183
|
+
if (resolvePath && /node_modules/.test(resolvePath)) return doExternal(resolvePath);
|
|
184
|
+
return callback();
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
function autoExternalNodeBuiltin({ request, dependencyType }, callback) {
|
|
188
|
+
if (!request) return void callback();
|
|
189
|
+
const isNodeBuiltin = utils.Tn.some((builtin)=>{
|
|
190
|
+
if ('string' == typeof builtin) return builtin === request;
|
|
191
|
+
return builtin.test(request);
|
|
192
|
+
});
|
|
193
|
+
if (isNodeBuiltin) callback(void 0, request, 'commonjs' === dependencyType ? 'commonjs' : 'module-import');
|
|
194
|
+
else callback();
|
|
195
|
+
}
|
|
196
|
+
const pluginExternal = (testEnvironment)=>({
|
|
197
|
+
name: 'rstest:external',
|
|
198
|
+
setup: (api)=>{
|
|
199
|
+
api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
|
|
200
|
+
output: {
|
|
201
|
+
externals: 'node' === testEnvironment ? [
|
|
202
|
+
autoExternalNodeModules
|
|
203
|
+
] : void 0
|
|
204
|
+
},
|
|
205
|
+
tools: {
|
|
206
|
+
rspack: (config)=>{
|
|
207
|
+
config.externals = (0, utils.XQ)(config.externals) || [];
|
|
208
|
+
config.externals.unshift({
|
|
209
|
+
'@rstest/core': 'global @rstest/core'
|
|
210
|
+
});
|
|
211
|
+
config.externalsPresets ??= {};
|
|
212
|
+
config.externalsPresets.node = false;
|
|
213
|
+
config.externals.push(autoExternalNodeBuiltin);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
});
|
|
89
219
|
class IgnoreModuleNotFoundErrorPlugin {
|
|
90
220
|
apply(compiler) {
|
|
91
221
|
compiler.hooks.done.tap('Rstest:IgnoreModuleNotFoundPlugin', (stats)=>{
|
|
@@ -137,8 +267,7 @@ Object.keys(originalRequire).forEach(key => {
|
|
|
137
267
|
|
|
138
268
|
__webpack_require__.rstest_original_modules = {};
|
|
139
269
|
|
|
140
|
-
|
|
141
|
-
__webpack_require__.rstest_reset_modules = __webpack_require__.reset_modules = () => {
|
|
270
|
+
__webpack_require__.rstest_reset_modules = () => {
|
|
142
271
|
const mockedIds = Object.keys(__webpack_require__.rstest_original_modules)
|
|
143
272
|
Object.keys(__webpack_module_cache__).forEach(id => {
|
|
144
273
|
// Do not reset mocks registry.
|
|
@@ -148,21 +277,27 @@ __webpack_require__.rstest_reset_modules = __webpack_require__.reset_modules = (
|
|
|
148
277
|
});
|
|
149
278
|
}
|
|
150
279
|
|
|
151
|
-
|
|
152
|
-
__webpack_require__.rstest_unmock = __webpack_require__.unmock = (id) => {
|
|
280
|
+
__webpack_require__.rstest_unmock = (id) => {
|
|
153
281
|
delete __webpack_module_cache__[id]
|
|
154
282
|
}
|
|
155
283
|
|
|
156
|
-
|
|
157
|
-
__webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = __webpack_require__.require_actual = __webpack_require__.import_actual = (id) => {
|
|
284
|
+
__webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id) => {
|
|
158
285
|
const originalModule = __webpack_require__.rstest_original_modules[id];
|
|
159
286
|
// Use fallback module if the module is not mocked.
|
|
160
287
|
const fallbackMod = __webpack_require__(id);
|
|
161
288
|
return originalModule ? originalModule : fallbackMod;
|
|
162
289
|
}
|
|
163
290
|
|
|
164
|
-
|
|
165
|
-
|
|
291
|
+
__webpack_require__.rstest_exec = async (id, modFactory) => {
|
|
292
|
+
if (__webpack_module_cache__) {
|
|
293
|
+
let asyncFactory = __webpack_module_cache__[id];
|
|
294
|
+
if (asyncFactory && asyncFactory.constructor.name === 'AsyncFunction') {
|
|
295
|
+
await asyncFactory();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
__webpack_require__.rstest_mock = (id, modFactory) => {
|
|
166
301
|
let requiredModule = undefined
|
|
167
302
|
try {
|
|
168
303
|
requiredModule = __webpack_require__(id);
|
|
@@ -174,11 +309,38 @@ __webpack_require__.rstest_set_mock = __webpack_require__.set_mock = (id, modFac
|
|
|
174
309
|
if (typeof modFactory === 'string' || typeof modFactory === 'number') {
|
|
175
310
|
__webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
|
|
176
311
|
} else if (typeof modFactory === 'function') {
|
|
177
|
-
|
|
312
|
+
if (modFactory.constructor.name === 'AsyncFunction') {
|
|
313
|
+
__webpack_module_cache__[id] = async () => {
|
|
314
|
+
const exports = await modFactory();
|
|
315
|
+
__webpack_require__.r(exports);
|
|
316
|
+
__webpack_module_cache__[id] = { exports, id, loaded: true };
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
const exports = modFactory();
|
|
320
|
+
__webpack_require__.r(exports);
|
|
321
|
+
__webpack_module_cache__[id] = { exports, id, loaded: true };
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
__webpack_require__.rstest_do_mock = (id, modFactory) => {
|
|
327
|
+
let requiredModule = undefined
|
|
328
|
+
try {
|
|
329
|
+
requiredModule = __webpack_require__(id);
|
|
330
|
+
} catch {
|
|
331
|
+
// TODO: non-resolved module
|
|
332
|
+
} finally {
|
|
333
|
+
__webpack_require__.rstest_original_modules[id] = requiredModule;
|
|
334
|
+
}
|
|
335
|
+
if (typeof modFactory === 'string' || typeof modFactory === 'number') {
|
|
336
|
+
__webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
|
|
337
|
+
} else if (typeof modFactory === 'function') {
|
|
338
|
+
const exports = modFactory();
|
|
178
339
|
__webpack_require__.r(exports);
|
|
179
340
|
__webpack_module_cache__[id] = { exports, id, loaded: true };
|
|
180
341
|
}
|
|
181
342
|
};
|
|
343
|
+
|
|
182
344
|
`;
|
|
183
345
|
}
|
|
184
346
|
}
|
|
@@ -249,38 +411,15 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
249
411
|
}
|
|
250
412
|
});
|
|
251
413
|
const isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isArray(compiler.compilers);
|
|
252
|
-
const autoExternalNodeModules = ({ context, request, dependencyType, getResolve }, callback)=>{
|
|
253
|
-
if (!request) return callback();
|
|
254
|
-
if (request.startsWith('@swc/helpers/')) return callback();
|
|
255
|
-
const doExternal = (externalPath = request)=>{
|
|
256
|
-
callback(void 0, externalPath, 'commonjs' === dependencyType ? 'commonjs' : 'import');
|
|
257
|
-
};
|
|
258
|
-
const resolver = getResolve?.();
|
|
259
|
-
if (!resolver) return callback();
|
|
260
|
-
resolver(context, request, (err, resolvePath)=>{
|
|
261
|
-
if (err) return callback();
|
|
262
|
-
if (resolvePath && /node_modules/.test(resolvePath)) return doExternal(resolvePath);
|
|
263
|
-
return callback();
|
|
264
|
-
});
|
|
265
|
-
};
|
|
266
|
-
const autoExternalNodeBuiltin = ({ request, dependencyType }, callback)=>{
|
|
267
|
-
if (!request) return callback();
|
|
268
|
-
const isNodeBuiltin = utils.Tn.some((builtin)=>{
|
|
269
|
-
if ('string' == typeof builtin) return builtin === request;
|
|
270
|
-
return builtin.test(request);
|
|
271
|
-
});
|
|
272
|
-
if (isNodeBuiltin) callback(void 0, request, 'commonjs' === dependencyType ? 'commonjs' : 'module-import');
|
|
273
|
-
else callback();
|
|
274
|
-
};
|
|
275
414
|
const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
|
|
276
|
-
const { command, normalizedConfig: { isolate,
|
|
415
|
+
const { command, normalizedConfig: { isolate, plugins, resolve, source, output, tools, testEnvironment, performance, dev = {} } } = context;
|
|
277
416
|
const debugMode = (0, utils.L1)();
|
|
278
417
|
core_.logger.level = debugMode ? 'verbose' : 'error';
|
|
279
418
|
const writeToDisk = dev.writeToDisk || debugMode;
|
|
280
419
|
const rsbuildInstance = await (0, core_.createRsbuild)({
|
|
420
|
+
callerName: 'rstest',
|
|
281
421
|
rsbuildConfig: {
|
|
282
422
|
tools,
|
|
283
|
-
plugins,
|
|
284
423
|
resolve,
|
|
285
424
|
source,
|
|
286
425
|
output,
|
|
@@ -293,97 +432,26 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
293
432
|
publicDir: false
|
|
294
433
|
},
|
|
295
434
|
dev: {
|
|
296
|
-
hmr: false
|
|
435
|
+
hmr: false,
|
|
436
|
+
writeToDisk
|
|
297
437
|
},
|
|
298
438
|
performance,
|
|
299
|
-
|
|
300
|
-
[
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
distPath: {
|
|
315
|
-
root: utils.Nk
|
|
316
|
-
},
|
|
317
|
-
target: 'node'
|
|
318
|
-
},
|
|
319
|
-
tools: {
|
|
320
|
-
rspack: (config, { isProd })=>{
|
|
321
|
-
config.mode = isProd ? 'production' : 'development';
|
|
322
|
-
config.output ??= {};
|
|
323
|
-
config.output.iife = false;
|
|
324
|
-
config.output.importFunctionName = '__rstest_dynamic_import__';
|
|
325
|
-
config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
|
|
326
|
-
config.plugins.push(new core_.rspack.experiments.RstestPlugin({
|
|
327
|
-
injectModulePathName: true,
|
|
328
|
-
importMetaPathName: true,
|
|
329
|
-
hoistMockModule: true,
|
|
330
|
-
manualMockRoot: external_pathe_["default"].resolve(context.rootPath, '__mocks__')
|
|
331
|
-
}));
|
|
332
|
-
config.externals = (0, utils.XQ)(config.externals) || [];
|
|
333
|
-
config.externals.unshift({
|
|
334
|
-
'@rstest/core': 'global @rstest/core'
|
|
335
|
-
});
|
|
336
|
-
if ('node' === testEnvironment) config.externals.push(autoExternalNodeModules);
|
|
337
|
-
config.externalsPresets ??= {};
|
|
338
|
-
config.externalsPresets.node = false;
|
|
339
|
-
config.externals.push(autoExternalNodeBuiltin);
|
|
340
|
-
config.module.parser ??= {};
|
|
341
|
-
config.module.parser.javascript = {
|
|
342
|
-
importDynamic: false,
|
|
343
|
-
requireDynamic: false,
|
|
344
|
-
requireAsExpression: false,
|
|
345
|
-
...config.module.parser.javascript || {}
|
|
346
|
-
};
|
|
347
|
-
config.resolve ??= {};
|
|
348
|
-
config.resolve.extensions ??= [];
|
|
349
|
-
config.resolve.extensions.push('.cjs');
|
|
350
|
-
if ('node' === testEnvironment) config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
|
|
351
|
-
'main'
|
|
352
|
-
];
|
|
353
|
-
config.resolve.byDependency ??= {};
|
|
354
|
-
config.resolve.byDependency.commonjs ??= {};
|
|
355
|
-
config.resolve.byDependency.commonjs.mainFields = [
|
|
356
|
-
'main',
|
|
357
|
-
'...'
|
|
358
|
-
];
|
|
359
|
-
config.optimization = {
|
|
360
|
-
moduleIds: 'named',
|
|
361
|
-
chunkIds: 'named',
|
|
362
|
-
nodeEnv: false,
|
|
363
|
-
...config.optimization || {},
|
|
364
|
-
runtimeChunk: {
|
|
365
|
-
name: 'runtime'
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
plugins: [
|
|
371
|
-
pluginIgnoreResolveError,
|
|
372
|
-
pluginMockRuntime,
|
|
373
|
-
pluginCSSFilter(),
|
|
374
|
-
pluginEntryWatch({
|
|
375
|
-
globTestSourceEntries,
|
|
376
|
-
setupFiles,
|
|
377
|
-
isWatch: 'watch' === command
|
|
378
|
-
})
|
|
379
|
-
]
|
|
380
|
-
}
|
|
381
|
-
}
|
|
439
|
+
plugins: [
|
|
440
|
+
...plugins || [],
|
|
441
|
+
pluginBasic(context),
|
|
442
|
+
pluginIgnoreResolveError,
|
|
443
|
+
pluginMockRuntime,
|
|
444
|
+
pluginCSSFilter(),
|
|
445
|
+
pluginEntryWatch({
|
|
446
|
+
globTestSourceEntries,
|
|
447
|
+
setupFiles,
|
|
448
|
+
isWatch: 'watch' === command
|
|
449
|
+
}),
|
|
450
|
+
pluginExternal(testEnvironment),
|
|
451
|
+
!isolate ? pluginCacheControl(Object.values(setupFiles)) : null
|
|
452
|
+
].filter(Boolean)
|
|
382
453
|
}
|
|
383
454
|
});
|
|
384
|
-
if (!isolate) rsbuildInstance.addPlugins([
|
|
385
|
-
pluginCacheControl(Object.values(setupFiles))
|
|
386
|
-
]);
|
|
387
455
|
return rsbuildInstance;
|
|
388
456
|
};
|
|
389
457
|
const createRsbuildServer = async ({ name, globTestSourceEntries, setupFiles, rsbuildInstance, normalizedConfig })=>{
|
|
@@ -586,8 +654,9 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
586
654
|
const numCpus = getNumCpus();
|
|
587
655
|
const { normalizedConfig: { pool: poolOptions, isolate }, reporters } = context;
|
|
588
656
|
const threadsCount = 'watch' === context.command ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
589
|
-
const
|
|
590
|
-
const
|
|
657
|
+
const recommendCount = 'watch' === context.command ? threadsCount : Math.min(Object.keys(entries).length, threadsCount);
|
|
658
|
+
const maxWorkers = poolOptions.maxWorkers ? parseWorkers(poolOptions.maxWorkers) : recommendCount;
|
|
659
|
+
const minWorkers = poolOptions.minWorkers ? parseWorkers(poolOptions.minWorkers) : maxWorkers < recommendCount ? maxWorkers : recommendCount;
|
|
591
660
|
if (maxWorkers < minWorkers) throw `Invalid pool configuration: maxWorkers(${maxWorkers}) cannot be less than minWorkers(${minWorkers}).`;
|
|
592
661
|
const pool = createForksPool({
|
|
593
662
|
...poolOptions,
|
package/dist/cli.js
CHANGED
|
@@ -2189,8 +2189,7 @@ var __webpack_modules__ = {
|
|
|
2189
2189
|
if (customConfig) {
|
|
2190
2190
|
const customConfigPath = (0, pathe__WEBPACK_IMPORTED_MODULE_2__.isAbsolute)(customConfig) ? customConfig : (0, pathe__WEBPACK_IMPORTED_MODULE_2__.join)(root, customConfig);
|
|
2191
2191
|
if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
2192
|
-
|
|
2193
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.kg.log('');
|
|
2192
|
+
throw `Cannot find config file: ${_utils__WEBPACK_IMPORTED_MODULE_3__.$_.dim(customConfigPath)}`;
|
|
2194
2193
|
}
|
|
2195
2194
|
const configFilePath = findConfig((0, pathe__WEBPACK_IMPORTED_MODULE_2__.join)(root, _utils__WEBPACK_IMPORTED_MODULE_3__.F7));
|
|
2196
2195
|
if (configFilePath) return configFilePath;
|
|
@@ -2199,7 +2198,7 @@ var __webpack_modules__ = {
|
|
|
2199
2198
|
async function loadConfig({ cwd = process.cwd(), path, envMode, configLoader }) {
|
|
2200
2199
|
const configFilePath = resolveConfigPath(cwd, path);
|
|
2201
2200
|
if (!configFilePath) {
|
|
2202
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.kg.debug('no config file found');
|
|
2201
|
+
_utils__WEBPACK_IMPORTED_MODULE_3__.kg.debug('no rstest config file found');
|
|
2203
2202
|
return {
|
|
2204
2203
|
content: {},
|
|
2205
2204
|
filePath: configFilePath
|
|
@@ -3686,11 +3685,12 @@ function initNodeEnv() {
|
|
|
3686
3685
|
}
|
|
3687
3686
|
function prepareCli() {
|
|
3688
3687
|
initNodeEnv();
|
|
3688
|
+
process.env.RSTEST = 'true';
|
|
3689
3689
|
const { npm_execpath } = process.env;
|
|
3690
3690
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
3691
3691
|
}
|
|
3692
3692
|
function showRstest() {
|
|
3693
|
-
logger.k.greet(" Rstest v0.0.
|
|
3693
|
+
logger.k.greet(" Rstest v0.0.10");
|
|
3694
3694
|
logger.k.log('');
|
|
3695
3695
|
}
|
|
3696
3696
|
const applyCommonOptions = (cli)=>{
|
|
@@ -3738,46 +3738,34 @@ async function initCli(options) {
|
|
|
3738
3738
|
function setupCommands() {
|
|
3739
3739
|
const cli = dist('rstest');
|
|
3740
3740
|
cli.help();
|
|
3741
|
-
cli.version("0.0.
|
|
3741
|
+
cli.version("0.0.10");
|
|
3742
3742
|
applyCommonOptions(cli);
|
|
3743
3743
|
cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
|
|
3744
3744
|
showRstest();
|
|
3745
|
+
if (external_std_env_.isCI) await runRest(options, filters, 'run');
|
|
3746
|
+
else await runRest(options, filters, 'watch');
|
|
3747
|
+
});
|
|
3748
|
+
const runRest = async (options, filters, command)=>{
|
|
3749
|
+
let rstest;
|
|
3745
3750
|
try {
|
|
3746
3751
|
const { config } = await initCli(options);
|
|
3747
3752
|
const { createRstest } = await __webpack_require__.e("353").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3748
|
-
|
|
3749
|
-
const rstest = createRstest(config, 'run', filters.map(external_pathe_.normalize));
|
|
3750
|
-
await rstest.runTests();
|
|
3751
|
-
} else {
|
|
3752
|
-
const rstest = createRstest(config, 'watch', filters.map(external_pathe_.normalize));
|
|
3753
|
-
await rstest.runTests();
|
|
3754
|
-
}
|
|
3755
|
-
} catch (err) {
|
|
3756
|
-
logger.k.error('Failed to run Rstest.');
|
|
3757
|
-
logger.k.error(err);
|
|
3758
|
-
process.exit(1);
|
|
3759
|
-
}
|
|
3760
|
-
});
|
|
3761
|
-
cli.command('run [...filters]', 'run tests without watch mode').action(async (filters, options)=>{
|
|
3762
|
-
showRstest();
|
|
3763
|
-
const { config } = await initCli(options);
|
|
3764
|
-
const { createRstest } = await __webpack_require__.e("353").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3765
|
-
const rstest = createRstest(config, 'run', filters.map(external_pathe_.normalize));
|
|
3766
|
-
try {
|
|
3753
|
+
rstest = createRstest(config, command, filters.map(external_pathe_.normalize));
|
|
3767
3754
|
await rstest.runTests();
|
|
3768
3755
|
} catch (err) {
|
|
3769
|
-
for (const reporter of rstest
|
|
3756
|
+
for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
|
|
3770
3757
|
logger.k.error('Failed to run Rstest.');
|
|
3771
3758
|
logger.k.error((0, helper.Z)(err));
|
|
3772
3759
|
process.exit(1);
|
|
3773
3760
|
}
|
|
3761
|
+
};
|
|
3762
|
+
cli.command('run [...filters]', 'run tests without watch mode').action(async (filters, options)=>{
|
|
3763
|
+
showRstest();
|
|
3764
|
+
await runRest(options, filters, 'run');
|
|
3774
3765
|
});
|
|
3775
3766
|
cli.command('watch [...filters]', 'run tests in watch mode').action(async (filters, options)=>{
|
|
3776
3767
|
showRstest();
|
|
3777
|
-
|
|
3778
|
-
const { createRstest } = await __webpack_require__.e("353").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3779
|
-
const rstest = createRstest(config, 'watch', filters.map(external_pathe_.normalize));
|
|
3780
|
-
await rstest.runTests();
|
|
3768
|
+
await runRest(options, filters, 'watch');
|
|
3781
3769
|
});
|
|
3782
3770
|
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)=>{
|
|
3783
3771
|
try {
|
package/dist/worker.js
CHANGED
|
@@ -2882,7 +2882,7 @@ var __webpack_modules__ = {
|
|
|
2882
2882
|
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
2883
2883
|
};
|
|
2884
2884
|
},
|
|
2885
|
-
"../../node_modules/.pnpm/jest-diff@30.0.
|
|
2885
|
+
"../../node_modules/.pnpm/jest-diff@30.0.5/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
2886
2886
|
/*!
|
|
2887
2887
|
* /**
|
|
2888
2888
|
* * Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -3747,7 +3747,7 @@ var __webpack_modules__ = {
|
|
|
3747
3747
|
});
|
|
3748
3748
|
var _chalk = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js"));
|
|
3749
3749
|
var _getType = __webpack_require__("../../node_modules/.pnpm/@jest+get-type@30.0.1/node_modules/@jest/get-type/build/index.js");
|
|
3750
|
-
var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.0.
|
|
3750
|
+
var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.0.5/node_modules/pretty-format/build/index.js");
|
|
3751
3751
|
var _cleanupSemantic = __nested_webpack_require_48295__("./src/cleanupSemantic.ts");
|
|
3752
3752
|
var _constants = __nested_webpack_require_48295__("./src/constants.ts");
|
|
3753
3753
|
var _diffLines = __nested_webpack_require_48295__("./src/diffLines.ts");
|
|
@@ -3931,7 +3931,7 @@ var __webpack_modules__ = {
|
|
|
3931
3931
|
module.exports = createColors();
|
|
3932
3932
|
module.exports.createColors = createColors;
|
|
3933
3933
|
},
|
|
3934
|
-
"../../node_modules/.pnpm/pretty-format@30.0.
|
|
3934
|
+
"../../node_modules/.pnpm/pretty-format@30.0.5/node_modules/pretty-format/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
3935
3935
|
/*!
|
|
3936
3936
|
* /**
|
|
3937
3937
|
* * Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -4973,7 +4973,7 @@ var __webpack_modules__ = {
|
|
|
4973
4973
|
o: ()=>formatTestError
|
|
4974
4974
|
});
|
|
4975
4975
|
var external_node_util_ = __webpack_require__("node:util");
|
|
4976
|
-
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.
|
|
4976
|
+
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.5/node_modules/jest-diff/build/index.js");
|
|
4977
4977
|
build.DIFF_DELETE;
|
|
4978
4978
|
build.DIFF_EQUAL;
|
|
4979
4979
|
build.DIFF_INSERT;
|
package/dist-types/public.d.ts
CHANGED
|
@@ -338,6 +338,8 @@ declare type MockContext<T extends FunctionLike = FunctionLike> = {
|
|
|
338
338
|
settledResults: MockSettledResult<Awaited<ReturnType<T>>>[];
|
|
339
339
|
};
|
|
340
340
|
|
|
341
|
+
declare type MockFactory<T = unknown> = () => MaybePromise<Partial<T>>;
|
|
342
|
+
|
|
341
343
|
declare type MockFn = <T extends FunctionLike = FunctionLike>(fn?: T) => Mock<T>;
|
|
342
344
|
|
|
343
345
|
declare interface MockInstance<T extends FunctionLike = FunctionLike> {
|
|
@@ -718,7 +720,7 @@ declare type RstestPoolOptions = {
|
|
|
718
720
|
|
|
719
721
|
declare type RstestPoolType = 'forks';
|
|
720
722
|
|
|
721
|
-
declare
|
|
723
|
+
declare interface RstestUtilities {
|
|
722
724
|
/**
|
|
723
725
|
* Creates a spy on a function.
|
|
724
726
|
*/
|
|
@@ -746,7 +748,7 @@ declare type RstestUtilities = {
|
|
|
746
748
|
/**
|
|
747
749
|
* Mock a module
|
|
748
750
|
*/
|
|
749
|
-
mock
|
|
751
|
+
mock<T = unknown>(moduleName: string | Promise<T>, moduleFactory?: MockFactory<T>): void;
|
|
750
752
|
/**
|
|
751
753
|
* Mock a module
|
|
752
754
|
*/
|
|
@@ -754,7 +756,7 @@ declare type RstestUtilities = {
|
|
|
754
756
|
/**
|
|
755
757
|
* Mock a module, not hoisted.
|
|
756
758
|
*/
|
|
757
|
-
doMock
|
|
759
|
+
doMock<T = unknown>(moduleName: string | Promise<T>, moduleFactory?: MockFactory<T>): void;
|
|
758
760
|
/**
|
|
759
761
|
* Mock a module, not hoisted.
|
|
760
762
|
*/
|
|
@@ -840,7 +842,7 @@ declare type RstestUtilities = {
|
|
|
840
842
|
* Removes all timers that are scheduled to run.
|
|
841
843
|
*/
|
|
842
844
|
clearAllTimers: () => RstestUtilities;
|
|
843
|
-
}
|
|
845
|
+
}
|
|
844
846
|
|
|
845
847
|
declare type RunnerAPI = {
|
|
846
848
|
describe: DescribeAPI;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"importMeta.d.ts"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@rsbuild/core": "1.4.
|
|
51
|
+
"@rsbuild/core": "1.4.9",
|
|
52
52
|
"@types/chai": "^5.2.2",
|
|
53
53
|
"@vitest/expect": "^3.2.4",
|
|
54
54
|
"@vitest/snapshot": "^3.2.4",
|
|
55
|
-
"birpc": "2.
|
|
55
|
+
"birpc": "2.5.0",
|
|
56
56
|
"chai": "^5.2.1",
|
|
57
57
|
"pathe": "^2.0.3",
|
|
58
58
|
"std-env": "^3.9.0",
|
|
@@ -61,8 +61,8 @@
|
|
|
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.
|
|
65
|
-
"@rslib/core": "0.
|
|
64
|
+
"@microsoft/api-extractor": "^7.52.9",
|
|
65
|
+
"@rslib/core": "0.11.0",
|
|
66
66
|
"@sinonjs/fake-timers": "^14.0.0",
|
|
67
67
|
"@types/babel__code-frame": "^7.0.6",
|
|
68
68
|
"@types/jsdom": "^21.1.7",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/source-map-support": "^0.5.10",
|
|
71
71
|
"cac": "^6.7.14",
|
|
72
72
|
"happy-dom": "^18.0.1",
|
|
73
|
-
"jest-diff": "^30.0.
|
|
73
|
+
"jest-diff": "^30.0.5",
|
|
74
74
|
"jsdom": "^26.1.0",
|
|
75
75
|
"license-webpack-plugin": "^4.0.2",
|
|
76
76
|
"picocolors": "^1.1.1",
|