@rstest/core 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/285.js +1 -1
- package/dist/355.js +4 -1
- package/dist/{612.js → 562.js} +194 -128
- package/dist/629.js +1 -0
- package/dist/64.js +1 -1
- package/dist/813.js +1 -1
- package/dist/867.js +1 -1
- package/dist/{353.js → 950.js} +87 -18
- package/dist/cli.js +30 -38
- package/dist/worker.js +13 -10
- package/dist-types/node.d.ts +38 -3
- package/dist-types/public.d.ts +44 -7
- package/dist-types/worker.d.ts +38 -3
- package/package.json +5 -5
package/dist/285.js
CHANGED
|
@@ -6,7 +6,7 @@ export const __webpack_modules__ = {
|
|
|
6
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
7
7
|
listTests: ()=>listTests
|
|
8
8
|
});
|
|
9
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
9
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
10
10
|
var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
|
|
11
11
|
var _pool__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/pool/index.ts");
|
|
12
12
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
package/dist/355.js
CHANGED
|
@@ -4,9 +4,10 @@ export const __webpack_ids__ = [
|
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"./src/utils/error.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
7
|
+
parseErrorStacktrace: ()=>parseErrorStacktrace,
|
|
7
8
|
printError: ()=>printError
|
|
8
9
|
});
|
|
9
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
10
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
10
11
|
var _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.29/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs");
|
|
11
12
|
var stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
|
|
12
13
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
@@ -70,6 +71,8 @@ export const __webpack_modules__ = {
|
|
|
70
71
|
/node_modules\/@vitest\/expect/,
|
|
71
72
|
/node_modules\/@vitest\/snapshot/,
|
|
72
73
|
/node:\w+/,
|
|
74
|
+
/webpack\/runtime/,
|
|
75
|
+
/webpack\\runtime/,
|
|
73
76
|
'<anonymous>'
|
|
74
77
|
];
|
|
75
78
|
async function parseErrorStacktrace({ stack, getSourcemap, fullStack }) {
|
package/dist/{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__) {
|
|
@@ -7,10 +7,94 @@ export const __webpack_modules__ = {
|
|
|
7
7
|
r: ()=>createRsbuildServer,
|
|
8
8
|
z: ()=>prepareRsbuild
|
|
9
9
|
});
|
|
10
|
-
var external_node_fs_ = __webpack_require__("fs");
|
|
10
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
11
11
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
12
12
|
var external_pathe_ = __webpack_require__("pathe");
|
|
13
13
|
var utils = __webpack_require__("./src/utils/index.ts");
|
|
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
|
-
function autoExternalNodeBuiltin({ request, dependencyType }, callback) {
|
|
267
|
-
if (!request) return void 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,100 +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
|
-
externals: 'node' === testEnvironment ? [
|
|
315
|
-
autoExternalNodeModules
|
|
316
|
-
] : void 0,
|
|
317
|
-
distPath: {
|
|
318
|
-
root: utils.Nk
|
|
319
|
-
},
|
|
320
|
-
target: 'node'
|
|
321
|
-
},
|
|
322
|
-
tools: {
|
|
323
|
-
rspack: (config, { isProd })=>{
|
|
324
|
-
config.mode = isProd ? 'production' : 'development';
|
|
325
|
-
config.output ??= {};
|
|
326
|
-
config.output.iife = false;
|
|
327
|
-
config.output.importFunctionName = '__rstest_dynamic_import__';
|
|
328
|
-
config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
|
|
329
|
-
config.plugins.push(new core_.rspack.experiments.RstestPlugin({
|
|
330
|
-
injectModulePathName: true,
|
|
331
|
-
importMetaPathName: true,
|
|
332
|
-
hoistMockModule: true,
|
|
333
|
-
manualMockRoot: external_pathe_["default"].resolve(context.rootPath, '__mocks__')
|
|
334
|
-
}));
|
|
335
|
-
config.externals = (0, utils.XQ)(config.externals) || [];
|
|
336
|
-
config.externals.unshift({
|
|
337
|
-
'@rstest/core': 'global @rstest/core'
|
|
338
|
-
});
|
|
339
|
-
config.externalsPresets ??= {};
|
|
340
|
-
config.externalsPresets.node = false;
|
|
341
|
-
config.externals.push(autoExternalNodeBuiltin);
|
|
342
|
-
config.module.parser ??= {};
|
|
343
|
-
config.module.parser.javascript = {
|
|
344
|
-
importDynamic: false,
|
|
345
|
-
requireDynamic: false,
|
|
346
|
-
requireAsExpression: false,
|
|
347
|
-
requireResolve: false,
|
|
348
|
-
...config.module.parser.javascript || {}
|
|
349
|
-
};
|
|
350
|
-
config.resolve ??= {};
|
|
351
|
-
config.resolve.extensions ??= [];
|
|
352
|
-
config.resolve.extensions.push('.cjs');
|
|
353
|
-
if ('node' === testEnvironment) config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
|
|
354
|
-
'main'
|
|
355
|
-
];
|
|
356
|
-
config.resolve.byDependency ??= {};
|
|
357
|
-
config.resolve.byDependency.commonjs ??= {};
|
|
358
|
-
config.resolve.byDependency.commonjs.mainFields = [
|
|
359
|
-
'main',
|
|
360
|
-
'...'
|
|
361
|
-
];
|
|
362
|
-
config.optimization = {
|
|
363
|
-
moduleIds: 'named',
|
|
364
|
-
chunkIds: 'named',
|
|
365
|
-
nodeEnv: false,
|
|
366
|
-
...config.optimization || {},
|
|
367
|
-
runtimeChunk: {
|
|
368
|
-
name: 'runtime'
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
plugins: [
|
|
374
|
-
pluginIgnoreResolveError,
|
|
375
|
-
pluginMockRuntime,
|
|
376
|
-
pluginCSSFilter(),
|
|
377
|
-
pluginEntryWatch({
|
|
378
|
-
globTestSourceEntries,
|
|
379
|
-
setupFiles,
|
|
380
|
-
isWatch: 'watch' === command
|
|
381
|
-
})
|
|
382
|
-
]
|
|
383
|
-
}
|
|
384
|
-
}
|
|
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)
|
|
385
453
|
}
|
|
386
454
|
});
|
|
387
|
-
if (!isolate) rsbuildInstance.addPlugins([
|
|
388
|
-
pluginCacheControl(Object.values(setupFiles))
|
|
389
|
-
]);
|
|
390
455
|
return rsbuildInstance;
|
|
391
456
|
};
|
|
392
457
|
const createRsbuildServer = async ({ name, globTestSourceEntries, setupFiles, rsbuildInstance, normalizedConfig })=>{
|
|
@@ -589,8 +654,9 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
589
654
|
const numCpus = getNumCpus();
|
|
590
655
|
const { normalizedConfig: { pool: poolOptions, isolate }, reporters } = context;
|
|
591
656
|
const threadsCount = 'watch' === context.command ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
592
|
-
const
|
|
593
|
-
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;
|
|
594
660
|
if (maxWorkers < minWorkers) throw `Invalid pool configuration: maxWorkers(${maxWorkers}) cannot be less than minWorkers(${minWorkers}).`;
|
|
595
661
|
const pool = createForksPool({
|
|
596
662
|
...poolOptions,
|
package/dist/629.js
CHANGED
|
@@ -71,6 +71,7 @@ export const __webpack_modules__ = {
|
|
|
71
71
|
};
|
|
72
72
|
if ('watch' === command) rsbuildInstance.onDevCompileDone(async ()=>{
|
|
73
73
|
await run();
|
|
74
|
+
_utils__WEBPACK_IMPORTED_MODULE_1__.kg.log(_utils__WEBPACK_IMPORTED_MODULE_1__.$_.green(' Waiting for file changes...'));
|
|
74
75
|
});
|
|
75
76
|
else {
|
|
76
77
|
const close = await run();
|
package/dist/64.js
CHANGED
|
@@ -38,7 +38,7 @@ export const __webpack_modules__ = {
|
|
|
38
38
|
var path = __webpack_require__("node:path");
|
|
39
39
|
var fs;
|
|
40
40
|
try {
|
|
41
|
-
fs = __webpack_require__("fs");
|
|
41
|
+
fs = __webpack_require__("node:fs");
|
|
42
42
|
if (!fs.existsSync || !fs.readFileSync) fs = null;
|
|
43
43
|
} catch (err) {}
|
|
44
44
|
var bufferFrom = __webpack_require__("../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js");
|
package/dist/813.js
CHANGED
|
@@ -132,7 +132,7 @@ export const __webpack_modules__ = {
|
|
|
132
132
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
133
133
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
134
134
|
__webpack_require__("./src/utils/logger.ts");
|
|
135
|
-
__webpack_require__("fs");
|
|
135
|
+
__webpack_require__("node:fs");
|
|
136
136
|
__webpack_require__("node:fs/promises");
|
|
137
137
|
__webpack_require__("node:module");
|
|
138
138
|
__webpack_require__("pathe");
|
package/dist/867.js
CHANGED
|
@@ -1743,7 +1743,7 @@ export const __webpack_modules__ = {
|
|
|
1743
1743
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
1744
1744
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
1745
1745
|
__webpack_require__("./src/utils/logger.ts");
|
|
1746
|
-
__webpack_require__("fs");
|
|
1746
|
+
__webpack_require__("node:fs");
|
|
1747
1747
|
__webpack_require__("node:fs/promises");
|
|
1748
1748
|
__webpack_require__("node:module");
|
|
1749
1749
|
__webpack_require__("pathe");
|
package/dist/{353.js → 950.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
"
|
|
2
|
+
"950"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -342,6 +342,23 @@ export const __webpack_modules__ = {
|
|
|
342
342
|
todo: utils.$_.gray(statusStr.todo),
|
|
343
343
|
skip: utils.$_.gray(statusStr.skip)
|
|
344
344
|
};
|
|
345
|
+
const logCase = (result, slowTestThreshold)=>{
|
|
346
|
+
const isSlowCase = (result.duration || 0) > slowTestThreshold;
|
|
347
|
+
const icon = isSlowCase && 'pass' === result.status ? utils.$_.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
|
|
348
|
+
const nameStr = (0, utils.Yz)(result);
|
|
349
|
+
const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration)})` : '';
|
|
350
|
+
const retry = result.retryCount ? utils.$_.yellow(` (retry x${result.retryCount})`) : '';
|
|
351
|
+
utils.kg.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}${retry}`);
|
|
352
|
+
if (result.errors) for (const error of result.errors)console.error(utils.$_.red(` ${error.message}`));
|
|
353
|
+
};
|
|
354
|
+
const logFileTitle = (test, relativePath, slowTestThreshold, alwaysShowTime = false)=>{
|
|
355
|
+
let title = ` ${utils.$_.bold(statusColorfulStr[test.status])} ${(0, utils.aj)(relativePath)}`;
|
|
356
|
+
const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](`${(0, utils.AS)(duration)}`);
|
|
357
|
+
title += ` ${utils.$_.gray(`(${test.results.length})`)}`;
|
|
358
|
+
const isTooSlow = test.duration && test.duration > slowTestThreshold;
|
|
359
|
+
if (alwaysShowTime || isTooSlow) title += ` ${formatDuration(test.duration)}`;
|
|
360
|
+
utils.kg.log(title);
|
|
361
|
+
};
|
|
345
362
|
class DefaultReporter {
|
|
346
363
|
rootPath;
|
|
347
364
|
config;
|
|
@@ -360,25 +377,15 @@ export const __webpack_modules__ = {
|
|
|
360
377
|
this.statusRenderer?.removeRunningModule(test.testPath);
|
|
361
378
|
const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
|
|
362
379
|
const { slowTestThreshold } = this.config;
|
|
363
|
-
|
|
364
|
-
const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](`${(0, utils.AS)(duration)}`);
|
|
365
|
-
title += ` ${utils.$_.gray(`(${test.results.length})`)}`;
|
|
380
|
+
logFileTitle(test, relativePath, slowTestThreshold);
|
|
366
381
|
const isTooSlow = test.duration && test.duration > slowTestThreshold;
|
|
367
|
-
if (isTooSlow) title += ` ${formatDuration(test.duration)}`;
|
|
368
382
|
const hasRetryCase = test.results.some((result)=>(result.retryCount || 0) > 0);
|
|
369
|
-
utils.kg.log(title);
|
|
370
383
|
if ('fail' !== test.status && !isTooSlow && !hasRetryCase) return;
|
|
371
384
|
const showAllCases = isTooSlow && !test.results.some((result)=>(result.duration || 0) > slowTestThreshold);
|
|
372
385
|
for (const result of test.results){
|
|
373
386
|
const isSlowCase = (result.duration || 0) > slowTestThreshold;
|
|
374
387
|
const retried = (result.retryCount || 0) > 0;
|
|
375
|
-
if (
|
|
376
|
-
const icon = isSlowCase && 'pass' === result.status ? utils.$_.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
|
|
377
|
-
const nameStr = (0, utils.Yz)(result);
|
|
378
|
-
const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration)})` : '';
|
|
379
|
-
const retry = result.retryCount ? utils.$_.yellow(` (retry x${result.retryCount})`) : '';
|
|
380
|
-
console.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}${retry}`);
|
|
381
|
-
if (result.errors) for (const error of result.errors)console.error(utils.$_.red(` ${error.message}`));
|
|
388
|
+
if (showAllCases || 'fail' === result.status || isSlowCase || retried) logCase(result, slowTestThreshold);
|
|
382
389
|
}
|
|
383
390
|
}
|
|
384
391
|
onTestCaseResult(_result) {}
|
|
@@ -420,14 +427,76 @@ export const __webpack_modules__ = {
|
|
|
420
427
|
});
|
|
421
428
|
}
|
|
422
429
|
}
|
|
430
|
+
class GithubActionsReporter {
|
|
431
|
+
onWritePath;
|
|
432
|
+
rootPath;
|
|
433
|
+
constructor({ options, rootPath }){
|
|
434
|
+
this.onWritePath = options.onWritePath;
|
|
435
|
+
this.rootPath = rootPath;
|
|
436
|
+
}
|
|
437
|
+
async onTestRunEnd({ results, testResults, getSourcemap }) {
|
|
438
|
+
const failedTests = [
|
|
439
|
+
...results.filter((i)=>'fail' === i.status && i.errors?.length),
|
|
440
|
+
...testResults.filter((i)=>'fail' === i.status)
|
|
441
|
+
];
|
|
442
|
+
if (0 === failedTests.length) return;
|
|
443
|
+
const { parseErrorStacktrace } = await Promise.all([
|
|
444
|
+
__webpack_require__.e("723"),
|
|
445
|
+
__webpack_require__.e("355")
|
|
446
|
+
]).then(__webpack_require__.bind(__webpack_require__, "./src/utils/error.ts"));
|
|
447
|
+
for (const test of failedTests){
|
|
448
|
+
const { testPath } = test;
|
|
449
|
+
const nameStr = (0, utils.Yz)(test);
|
|
450
|
+
const shortPath = (0, external_pathe_.relative)(this.rootPath, testPath);
|
|
451
|
+
const title = `${shortPath} ${utils.Qd} ${nameStr}`;
|
|
452
|
+
for (const error of test.errors || []){
|
|
453
|
+
let file = testPath;
|
|
454
|
+
let line = 1;
|
|
455
|
+
let column = 1;
|
|
456
|
+
const message = `${error.message}${error.diff ? `\n${error.diff}` : ''}`;
|
|
457
|
+
const type = 'error';
|
|
458
|
+
if (error.stack) {
|
|
459
|
+
const stackFrames = await parseErrorStacktrace({
|
|
460
|
+
stack: error.stack,
|
|
461
|
+
fullStack: error.fullStack,
|
|
462
|
+
getSourcemap
|
|
463
|
+
});
|
|
464
|
+
if (stackFrames[0]) {
|
|
465
|
+
file = stackFrames[0].file || test.testPath;
|
|
466
|
+
line = stackFrames[0].lineNumber || 1;
|
|
467
|
+
column = stackFrames[0].column || 1;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
utils.kg.log(`::${type} file=${this.onWritePath?.(file) || file},line=${line},col=${column},title=${escapeData(title)}::${escapeData(message)}`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
function escapeData(s) {
|
|
476
|
+
return s.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/:/g, '%3A').replace(/,/g, '%2C');
|
|
477
|
+
}
|
|
478
|
+
class VerboseReporter extends DefaultReporter {
|
|
479
|
+
onTestFileResult(test) {
|
|
480
|
+
this.statusRenderer?.removeRunningModule(test.testPath);
|
|
481
|
+
const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
|
|
482
|
+
const { slowTestThreshold } = this.config;
|
|
483
|
+
logFileTitle(test, relativePath, slowTestThreshold, true);
|
|
484
|
+
for (const result of test.results)logCase(result, slowTestThreshold);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
423
487
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
424
488
|
const reportersMap = {
|
|
425
|
-
default: DefaultReporter
|
|
489
|
+
default: DefaultReporter,
|
|
490
|
+
verbose: VerboseReporter,
|
|
491
|
+
'github-actions': GithubActionsReporter
|
|
426
492
|
};
|
|
427
493
|
function createReporters(reporters, initOptions = {}) {
|
|
428
494
|
const result = (0, helper.XQ)(reporters).map((reporter)=>{
|
|
429
495
|
if ('string' == typeof reporter || Array.isArray(reporter)) {
|
|
430
|
-
const [name, options = {}] =
|
|
496
|
+
const [name, options = {}] = 'string' == typeof reporter ? [
|
|
497
|
+
reporter,
|
|
498
|
+
{}
|
|
499
|
+
] : reporter;
|
|
431
500
|
if (name in reportersMap) {
|
|
432
501
|
const Reporter = reportersMap[name];
|
|
433
502
|
return new Reporter({
|
|
@@ -454,7 +523,7 @@ export const __webpack_modules__ = {
|
|
|
454
523
|
});
|
|
455
524
|
return {
|
|
456
525
|
command,
|
|
457
|
-
version: "0.0
|
|
526
|
+
version: "0.1.0",
|
|
458
527
|
rootPath,
|
|
459
528
|
reporters,
|
|
460
529
|
snapshotManager,
|
|
@@ -469,14 +538,14 @@ export const __webpack_modules__ = {
|
|
|
469
538
|
}, config);
|
|
470
539
|
const runTests = async ()=>{
|
|
471
540
|
const { runTests } = await Promise.all([
|
|
472
|
-
__webpack_require__.e("
|
|
541
|
+
__webpack_require__.e("562"),
|
|
473
542
|
__webpack_require__.e("629")
|
|
474
543
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
|
|
475
544
|
await runTests(context, fileFilters);
|
|
476
545
|
};
|
|
477
546
|
const listTests = async (options)=>{
|
|
478
547
|
const { listTests } = await Promise.all([
|
|
479
|
-
__webpack_require__.e("
|
|
548
|
+
__webpack_require__.e("562"),
|
|
480
549
|
__webpack_require__.e("285")
|
|
481
550
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
|
|
482
551
|
await listTests(context, fileFilters, options);
|
package/dist/cli.js
CHANGED
|
@@ -233,7 +233,7 @@ var __webpack_modules__ = {
|
|
|
233
233
|
value: true
|
|
234
234
|
});
|
|
235
235
|
exports.build = void 0;
|
|
236
|
-
const fs_1 = __importDefault(__webpack_require__("fs"));
|
|
236
|
+
const fs_1 = __importDefault(__webpack_require__("node:fs"));
|
|
237
237
|
const path_1 = __webpack_require__("node:path");
|
|
238
238
|
const resolveSymlinksAsync = function(path, state, callback) {
|
|
239
239
|
const { queue, options: { suppressErrors } } = state;
|
|
@@ -292,7 +292,7 @@ var __webpack_modules__ = {
|
|
|
292
292
|
value: true
|
|
293
293
|
});
|
|
294
294
|
exports.build = void 0;
|
|
295
|
-
const fs_1 = __importDefault(__webpack_require__("fs"));
|
|
295
|
+
const fs_1 = __importDefault(__webpack_require__("node:fs"));
|
|
296
296
|
const readdirOpts = {
|
|
297
297
|
withFileTypes: true
|
|
298
298
|
};
|
|
@@ -2180,7 +2180,7 @@ var __webpack_modules__ = {
|
|
|
2180
2180
|
ME: ()=>loadConfig,
|
|
2181
2181
|
hY: ()=>withDefaultConfig
|
|
2182
2182
|
});
|
|
2183
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
2183
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
2184
2184
|
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
2185
2185
|
var pathe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("pathe");
|
|
2186
2186
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
@@ -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
|
|
@@ -2240,7 +2239,10 @@ var __webpack_modules__ = {
|
|
|
2240
2239
|
hookTimeout: 10000,
|
|
2241
2240
|
testEnvironment: 'node',
|
|
2242
2241
|
retry: 0,
|
|
2243
|
-
reporters: [
|
|
2242
|
+
reporters: 'true' === process.env.GITHUB_ACTIONS ? [
|
|
2243
|
+
'default',
|
|
2244
|
+
'github-actions'
|
|
2245
|
+
] : [
|
|
2244
2246
|
'default'
|
|
2245
2247
|
],
|
|
2246
2248
|
clearMocks: false,
|
|
@@ -2464,7 +2466,7 @@ var __webpack_modules__ = {
|
|
|
2464
2466
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
2465
2467
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
2466
2468
|
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
2467
|
-
var external_node_fs_ = __webpack_require__("fs");
|
|
2469
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
2468
2470
|
var promises_ = __webpack_require__("node:fs/promises");
|
|
2469
2471
|
var external_node_module_ = __webpack_require__("node:module");
|
|
2470
2472
|
var external_pathe_ = __webpack_require__("pathe");
|
|
@@ -2849,7 +2851,7 @@ var __webpack_modules__ = {
|
|
|
2849
2851
|
"node:events": function(module) {
|
|
2850
2852
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__;
|
|
2851
2853
|
},
|
|
2852
|
-
fs: function(module) {
|
|
2854
|
+
"node:fs": function(module) {
|
|
2853
2855
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
2854
2856
|
},
|
|
2855
2857
|
"node:fs/promises": function(module) {
|
|
@@ -3686,17 +3688,18 @@ function initNodeEnv() {
|
|
|
3686
3688
|
}
|
|
3687
3689
|
function prepareCli() {
|
|
3688
3690
|
initNodeEnv();
|
|
3691
|
+
process.env.RSTEST = 'true';
|
|
3689
3692
|
const { npm_execpath } = process.env;
|
|
3690
3693
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
3691
3694
|
}
|
|
3692
3695
|
function showRstest() {
|
|
3693
|
-
logger.k.greet(" Rstest v0.0
|
|
3696
|
+
logger.k.greet(" Rstest v0.1.0");
|
|
3694
3697
|
logger.k.log('');
|
|
3695
3698
|
}
|
|
3696
3699
|
const applyCommonOptions = (cli)=>{
|
|
3697
3700
|
cli.option('-c, --config <config>', 'Specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'Specify the loader to load the config file, can be `jiti` or `native`', {
|
|
3698
3701
|
default: 'jiti'
|
|
3699
|
-
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
3702
|
+
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('--reporter <reporter>', 'Specify the reporter to use').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
3700
3703
|
};
|
|
3701
3704
|
async function initCli(options) {
|
|
3702
3705
|
const cwd = process.cwd();
|
|
@@ -3729,6 +3732,7 @@ async function initCli(options) {
|
|
|
3729
3732
|
];
|
|
3730
3733
|
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
3731
3734
|
if (options.exclude) config.exclude = (0, helper.XQ)(options.exclude);
|
|
3735
|
+
if (options.reporter) config.reporters = (0, helper.XQ)(options.reporter);
|
|
3732
3736
|
if (options.include) config.include = (0, helper.XQ)(options.include);
|
|
3733
3737
|
return {
|
|
3734
3738
|
config,
|
|
@@ -3738,51 +3742,39 @@ async function initCli(options) {
|
|
|
3738
3742
|
function setupCommands() {
|
|
3739
3743
|
const cli = dist('rstest');
|
|
3740
3744
|
cli.help();
|
|
3741
|
-
cli.version("0.0
|
|
3745
|
+
cli.version("0.1.0");
|
|
3742
3746
|
applyCommonOptions(cli);
|
|
3743
3747
|
cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
|
|
3744
3748
|
showRstest();
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
const { createRstest } = await __webpack_require__.e("353").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3748
|
-
if (external_std_env_.isCI) {
|
|
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
|
-
}
|
|
3749
|
+
if (external_std_env_.isCI) await runRest(options, filters, 'run');
|
|
3750
|
+
else await runRest(options, filters, 'watch');
|
|
3760
3751
|
});
|
|
3761
|
-
|
|
3762
|
-
|
|
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));
|
|
3752
|
+
const runRest = async (options, filters, command)=>{
|
|
3753
|
+
let rstest;
|
|
3766
3754
|
try {
|
|
3755
|
+
const { config } = await initCli(options);
|
|
3756
|
+
const { createRstest } = await __webpack_require__.e("950").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3757
|
+
rstest = createRstest(config, command, filters.map(external_pathe_.normalize));
|
|
3767
3758
|
await rstest.runTests();
|
|
3768
3759
|
} catch (err) {
|
|
3769
|
-
for (const reporter of rstest
|
|
3760
|
+
for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
|
|
3770
3761
|
logger.k.error('Failed to run Rstest.');
|
|
3771
3762
|
logger.k.error((0, helper.Z)(err));
|
|
3772
3763
|
process.exit(1);
|
|
3773
3764
|
}
|
|
3765
|
+
};
|
|
3766
|
+
cli.command('run [...filters]', 'run tests without watch mode').action(async (filters, options)=>{
|
|
3767
|
+
showRstest();
|
|
3768
|
+
await runRest(options, filters, 'run');
|
|
3774
3769
|
});
|
|
3775
3770
|
cli.command('watch [...filters]', 'run tests in watch mode').action(async (filters, options)=>{
|
|
3776
3771
|
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();
|
|
3772
|
+
await runRest(options, filters, 'watch');
|
|
3781
3773
|
});
|
|
3782
3774
|
cli.command('list [...filters]', 'lists all test files that Rstest will run').option('--filesOnly', 'only list the test files').option('--json [boolean/path]', 'print tests as JSON or write to a file').action(async (filters, options)=>{
|
|
3783
3775
|
try {
|
|
3784
3776
|
const { config } = await initCli(options);
|
|
3785
|
-
const { createRstest } = await __webpack_require__.e("
|
|
3777
|
+
const { createRstest } = await __webpack_require__.e("950").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3786
3778
|
const rstest = createRstest(config, 'list', filters.map(external_pathe_.normalize));
|
|
3787
3779
|
await rstest.listTests({
|
|
3788
3780
|
filesOnly: options.filesOnly,
|
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;
|
|
@@ -5414,7 +5414,7 @@ var __webpack_modules__ = {
|
|
|
5414
5414
|
"node:console": function(module) {
|
|
5415
5415
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
|
|
5416
5416
|
},
|
|
5417
|
-
fs: function(module) {
|
|
5417
|
+
"node:fs": function(module) {
|
|
5418
5418
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
5419
5419
|
},
|
|
5420
5420
|
"node:fs/promises": function(module) {
|
|
@@ -5568,6 +5568,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
5568
5568
|
};
|
|
5569
5569
|
})();
|
|
5570
5570
|
__webpack_require__("./src/runtime/worker/setup.ts");
|
|
5571
|
+
var external_node_timers_ = __webpack_require__("node:timers");
|
|
5571
5572
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
5572
5573
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
5573
5574
|
var util = __webpack_require__("./src/runtime/util.ts");
|
|
@@ -5815,13 +5816,14 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5815
5816
|
listeners.length = 0;
|
|
5816
5817
|
const unhandledErrors = [];
|
|
5817
5818
|
const handleError = (e, type)=>{
|
|
5818
|
-
|
|
5819
|
+
const error = 'string' == typeof e ? new Error(e) : e;
|
|
5820
|
+
error.name = type;
|
|
5819
5821
|
if (isTeardown) {
|
|
5820
|
-
|
|
5821
|
-
console.error(
|
|
5822
|
+
error.stack = `${helper.$_.yellow('Caught error after test environment was torn down:')}\n\n${error.stack}`;
|
|
5823
|
+
console.error(error);
|
|
5822
5824
|
} else {
|
|
5823
|
-
console.error(
|
|
5824
|
-
unhandledErrors.push(
|
|
5825
|
+
console.error(error);
|
|
5826
|
+
unhandledErrors.push(error);
|
|
5825
5827
|
}
|
|
5826
5828
|
};
|
|
5827
5829
|
const uncaughtException = (e)=>handleError(e, 'uncaughtException');
|
|
@@ -5908,6 +5910,7 @@ const runInPool = async (options)=>{
|
|
|
5908
5910
|
});
|
|
5909
5911
|
process.off('SIGTERM', onExit);
|
|
5910
5912
|
const teardown = async ()=>{
|
|
5913
|
+
await new Promise((resolve)=>(0, external_node_timers_.setTimeout)(resolve));
|
|
5911
5914
|
await Promise.all(cleanups.map((fn)=>fn()));
|
|
5912
5915
|
isTeardown = true;
|
|
5913
5916
|
process.once('SIGTERM', onExit);
|
package/dist-types/node.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ declare interface DecodedSourceMap extends SourceMapV3 {
|
|
|
15
15
|
declare type DecodedSourceMapXInput = DecodedSourceMap & XInput;
|
|
16
16
|
|
|
17
17
|
declare class DefaultReporter implements Reporter {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
protected rootPath: string;
|
|
19
|
+
protected config: NormalizedConfig;
|
|
20
20
|
private options;
|
|
21
|
-
|
|
21
|
+
protected statusRenderer: StatusRenderer | undefined;
|
|
22
22
|
constructor({ rootPath, options, config, }: {
|
|
23
23
|
rootPath: string;
|
|
24
24
|
config: NormalizedConfig;
|
|
@@ -70,6 +70,24 @@ declare type GeneratedColumn = number;
|
|
|
70
70
|
|
|
71
71
|
declare type GetSourcemap = (sourcePath: string) => SourceMapInput | null;
|
|
72
72
|
|
|
73
|
+
declare class GithubActionsReporter {
|
|
74
|
+
private onWritePath;
|
|
75
|
+
private rootPath;
|
|
76
|
+
constructor({ options, rootPath, }: {
|
|
77
|
+
rootPath: string;
|
|
78
|
+
options: {
|
|
79
|
+
onWritePath: (path: string) => string;
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
83
|
+
results: TestFileResult[];
|
|
84
|
+
testResults: TestResult[];
|
|
85
|
+
duration: Duration;
|
|
86
|
+
snapshotSummary: SnapshotSummary;
|
|
87
|
+
getSourcemap: GetSourcemap;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
|
|
73
91
|
declare type MaybePromise<T> = T | Promise<T>;
|
|
74
92
|
|
|
75
93
|
declare type NamesIndex = number;
|
|
@@ -117,6 +135,8 @@ export declare interface Reporter {
|
|
|
117
135
|
|
|
118
136
|
declare const reportersMap: {
|
|
119
137
|
default: typeof DefaultReporter;
|
|
138
|
+
verbose: typeof VerboseReporter;
|
|
139
|
+
'github-actions': typeof GithubActionsReporter;
|
|
120
140
|
};
|
|
121
141
|
|
|
122
142
|
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
@@ -328,6 +348,17 @@ declare interface SourceMapV3 {
|
|
|
328
348
|
|
|
329
349
|
declare type SourcesIndex = number;
|
|
330
350
|
|
|
351
|
+
declare class StatusRenderer {
|
|
352
|
+
private rootPath;
|
|
353
|
+
private renderer;
|
|
354
|
+
private runningModules;
|
|
355
|
+
constructor(rootPath: string);
|
|
356
|
+
getContent(): string[];
|
|
357
|
+
addRunningModule(testPath: string): void;
|
|
358
|
+
removeRunningModule(testPath: string): void;
|
|
359
|
+
clear(): void;
|
|
360
|
+
}
|
|
361
|
+
|
|
331
362
|
export declare type TestFileInfo = {
|
|
332
363
|
testPath: TestPath;
|
|
333
364
|
};
|
|
@@ -377,6 +408,10 @@ declare interface UserConsoleLog {
|
|
|
377
408
|
type: 'stdout' | 'stderr';
|
|
378
409
|
}
|
|
379
410
|
|
|
411
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
412
|
+
onTestFileResult(test: TestFileResult): void;
|
|
413
|
+
}
|
|
414
|
+
|
|
380
415
|
declare type XInput = {
|
|
381
416
|
x_google_ignoreList?: SourceMapV3['ignoreList'];
|
|
382
417
|
};
|
package/dist-types/public.d.ts
CHANGED
|
@@ -93,10 +93,10 @@ declare interface DecodedSourceMap extends SourceMapV3 {
|
|
|
93
93
|
declare type DecodedSourceMapXInput = DecodedSourceMap & XInput;
|
|
94
94
|
|
|
95
95
|
declare class DefaultReporter implements Reporter {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
protected rootPath: string;
|
|
97
|
+
protected config: NormalizedConfig;
|
|
98
98
|
private options;
|
|
99
|
-
|
|
99
|
+
protected statusRenderer: StatusRenderer | undefined;
|
|
100
100
|
constructor({ rootPath, options, config, }: {
|
|
101
101
|
rootPath: string;
|
|
102
102
|
config: NormalizedConfig;
|
|
@@ -283,6 +283,24 @@ declare type GeneratedColumn = number;
|
|
|
283
283
|
|
|
284
284
|
declare type GetSourcemap = (sourcePath: string) => SourceMapInput | null;
|
|
285
285
|
|
|
286
|
+
declare class GithubActionsReporter {
|
|
287
|
+
private onWritePath;
|
|
288
|
+
private rootPath;
|
|
289
|
+
constructor({ options, rootPath, }: {
|
|
290
|
+
rootPath: string;
|
|
291
|
+
options: {
|
|
292
|
+
onWritePath: (path: string) => string;
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
296
|
+
results: TestFileResult[];
|
|
297
|
+
testResults: TestResult[];
|
|
298
|
+
duration: Duration;
|
|
299
|
+
snapshotSummary: SnapshotSummary;
|
|
300
|
+
getSourcemap: GetSourcemap;
|
|
301
|
+
}): Promise<void>;
|
|
302
|
+
}
|
|
303
|
+
|
|
286
304
|
declare interface InlineSnapshotMatcher<T> {
|
|
287
305
|
<U extends {
|
|
288
306
|
[P in keyof T]: any;
|
|
@@ -338,6 +356,8 @@ declare type MockContext<T extends FunctionLike = FunctionLike> = {
|
|
|
338
356
|
settledResults: MockSettledResult<Awaited<ReturnType<T>>>[];
|
|
339
357
|
};
|
|
340
358
|
|
|
359
|
+
declare type MockFactory<T = unknown> = () => MaybePromise<Partial<T>>;
|
|
360
|
+
|
|
341
361
|
declare type MockFn = <T extends FunctionLike = FunctionLike>(fn?: T) => Mock<T>;
|
|
342
362
|
|
|
343
363
|
declare interface MockInstance<T extends FunctionLike = FunctionLike> {
|
|
@@ -499,6 +519,8 @@ declare interface Reporter {
|
|
|
499
519
|
|
|
500
520
|
declare const reportersMap: {
|
|
501
521
|
default: typeof DefaultReporter;
|
|
522
|
+
verbose: typeof VerboseReporter;
|
|
523
|
+
'github-actions': typeof GithubActionsReporter;
|
|
502
524
|
};
|
|
503
525
|
|
|
504
526
|
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
@@ -718,7 +740,7 @@ declare type RstestPoolOptions = {
|
|
|
718
740
|
|
|
719
741
|
declare type RstestPoolType = 'forks';
|
|
720
742
|
|
|
721
|
-
declare
|
|
743
|
+
declare interface RstestUtilities {
|
|
722
744
|
/**
|
|
723
745
|
* Creates a spy on a function.
|
|
724
746
|
*/
|
|
@@ -746,7 +768,7 @@ declare type RstestUtilities = {
|
|
|
746
768
|
/**
|
|
747
769
|
* Mock a module
|
|
748
770
|
*/
|
|
749
|
-
mock
|
|
771
|
+
mock<T = unknown>(moduleName: string | Promise<T>, moduleFactory?: MockFactory<T>): void;
|
|
750
772
|
/**
|
|
751
773
|
* Mock a module
|
|
752
774
|
*/
|
|
@@ -754,7 +776,7 @@ declare type RstestUtilities = {
|
|
|
754
776
|
/**
|
|
755
777
|
* Mock a module, not hoisted.
|
|
756
778
|
*/
|
|
757
|
-
doMock
|
|
779
|
+
doMock<T = unknown>(moduleName: string | Promise<T>, moduleFactory?: MockFactory<T>): void;
|
|
758
780
|
/**
|
|
759
781
|
* Mock a module, not hoisted.
|
|
760
782
|
*/
|
|
@@ -840,7 +862,7 @@ declare type RstestUtilities = {
|
|
|
840
862
|
* Removes all timers that are scheduled to run.
|
|
841
863
|
*/
|
|
842
864
|
clearAllTimers: () => RstestUtilities;
|
|
843
|
-
}
|
|
865
|
+
}
|
|
844
866
|
|
|
845
867
|
declare type RunnerAPI = {
|
|
846
868
|
describe: DescribeAPI;
|
|
@@ -894,6 +916,17 @@ declare interface SourceMapV3 {
|
|
|
894
916
|
|
|
895
917
|
declare type SourcesIndex = number;
|
|
896
918
|
|
|
919
|
+
declare class StatusRenderer {
|
|
920
|
+
private rootPath;
|
|
921
|
+
private renderer;
|
|
922
|
+
private runningModules;
|
|
923
|
+
constructor(rootPath: string);
|
|
924
|
+
getContent(): string[];
|
|
925
|
+
addRunningModule(testPath: string): void;
|
|
926
|
+
removeRunningModule(testPath: string): void;
|
|
927
|
+
clear(): void;
|
|
928
|
+
}
|
|
929
|
+
|
|
897
930
|
declare type SuiteContext = {
|
|
898
931
|
filepath: TestPath;
|
|
899
932
|
};
|
|
@@ -985,6 +1018,10 @@ declare interface UserConsoleLog {
|
|
|
985
1018
|
type: 'stdout' | 'stderr';
|
|
986
1019
|
}
|
|
987
1020
|
|
|
1021
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
1022
|
+
onTestFileResult(test: TestFileResult): void;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
988
1025
|
declare type XInput = {
|
|
989
1026
|
x_google_ignoreList?: SourceMapV3['ignoreList'];
|
|
990
1027
|
};
|
package/dist-types/worker.d.ts
CHANGED
|
@@ -83,10 +83,10 @@ declare interface DecodedSourceMap extends SourceMapV3 {
|
|
|
83
83
|
declare type DecodedSourceMapXInput = DecodedSourceMap & XInput;
|
|
84
84
|
|
|
85
85
|
declare class DefaultReporter implements Reporter {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
protected rootPath: string;
|
|
87
|
+
protected config: NormalizedConfig;
|
|
88
88
|
private options;
|
|
89
|
-
|
|
89
|
+
protected statusRenderer: StatusRenderer | undefined;
|
|
90
90
|
constructor({ rootPath, options, config, }: {
|
|
91
91
|
rootPath: string;
|
|
92
92
|
config: NormalizedConfig;
|
|
@@ -181,6 +181,24 @@ declare type GeneratedColumn = number;
|
|
|
181
181
|
|
|
182
182
|
declare type GetSourcemap = (sourcePath: string) => SourceMapInput | null;
|
|
183
183
|
|
|
184
|
+
declare class GithubActionsReporter {
|
|
185
|
+
private onWritePath;
|
|
186
|
+
private rootPath;
|
|
187
|
+
constructor({ options, rootPath, }: {
|
|
188
|
+
rootPath: string;
|
|
189
|
+
options: {
|
|
190
|
+
onWritePath: (path: string) => string;
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
194
|
+
results: TestFileResult[];
|
|
195
|
+
testResults: TestResult[];
|
|
196
|
+
duration: Duration;
|
|
197
|
+
snapshotSummary: SnapshotSummary;
|
|
198
|
+
getSourcemap: GetSourcemap;
|
|
199
|
+
}): Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
|
|
184
202
|
declare interface InlineSnapshotMatcher<T> {
|
|
185
203
|
<U extends {
|
|
186
204
|
[P in keyof T]: any;
|
|
@@ -255,6 +273,8 @@ declare interface Reporter {
|
|
|
255
273
|
|
|
256
274
|
declare const reportersMap: {
|
|
257
275
|
default: typeof DefaultReporter;
|
|
276
|
+
verbose: typeof VerboseReporter;
|
|
277
|
+
'github-actions': typeof GithubActionsReporter;
|
|
258
278
|
};
|
|
259
279
|
|
|
260
280
|
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
@@ -524,6 +544,17 @@ declare interface SourceMapV3 {
|
|
|
524
544
|
|
|
525
545
|
declare type SourcesIndex = number;
|
|
526
546
|
|
|
547
|
+
declare class StatusRenderer {
|
|
548
|
+
private rootPath;
|
|
549
|
+
private renderer;
|
|
550
|
+
private runningModules;
|
|
551
|
+
constructor(rootPath: string);
|
|
552
|
+
getContent(): string[];
|
|
553
|
+
addRunningModule(testPath: string): void;
|
|
554
|
+
removeRunningModule(testPath: string): void;
|
|
555
|
+
clear(): void;
|
|
556
|
+
}
|
|
557
|
+
|
|
527
558
|
declare type SuiteContext = {
|
|
528
559
|
filepath: TestPath;
|
|
529
560
|
};
|
|
@@ -650,6 +681,10 @@ declare interface UserConsoleLog {
|
|
|
650
681
|
type: 'stdout' | 'stderr';
|
|
651
682
|
}
|
|
652
683
|
|
|
684
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
685
|
+
onTestFileResult(test: TestFileResult): void;
|
|
686
|
+
}
|
|
687
|
+
|
|
653
688
|
declare type WorkerContext = {
|
|
654
689
|
rootPath: RstestContext['rootPath'];
|
|
655
690
|
runtimeConfig: RuntimeConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"importMeta.d.ts"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@rsbuild/core": "1.4.
|
|
51
|
+
"@rsbuild/core": "1.4.12",
|
|
52
52
|
"@types/chai": "^5.2.2",
|
|
53
53
|
"@vitest/expect": "^3.2.4",
|
|
54
54
|
"@vitest/snapshot": "^3.2.4",
|
|
@@ -61,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.10",
|
|
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",
|