@rstest/core 0.7.7 → 0.7.9

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.
Files changed (57) hide show
  1. package/LICENSE.md +294 -0
  2. package/dist/0~130.js +2 -2
  3. package/dist/0~1472.js +48 -0
  4. package/dist/0~1981.js +3 -0
  5. package/dist/0~2173.js +25 -10
  6. package/dist/0~2255.js +2 -2
  7. package/dist/0~3062.js +0 -5
  8. package/dist/0~3919.js +1 -1
  9. package/dist/0~4403.js +6 -5
  10. package/dist/0~4809.js +4 -4
  11. package/dist/0~5835.js +2 -2
  12. package/dist/0~62.js +3 -3
  13. package/dist/0~6588.js +3 -3
  14. package/dist/0~6923.js +2 -2
  15. package/dist/0~7583.js +9 -8
  16. package/dist/0~7882.js +1144 -0
  17. package/dist/0~8426.js +1 -2
  18. package/dist/0~89.js +33 -24
  19. package/dist/0~9348.js +953 -0
  20. package/dist/0~9634.js +58 -10
  21. package/dist/1157.js +13 -118
  22. package/dist/{7913.js → 1294.js} +51 -1745
  23. package/dist/2672.js +647 -0
  24. package/dist/3278.js +3 -450
  25. package/dist/4484.js +38 -0
  26. package/dist/487.js +1739 -0
  27. package/dist/4899.js +11 -0
  28. package/dist/5734.js +1 -1
  29. package/dist/{0~6151.js → 6151.js} +169 -21
  30. package/dist/{0~6973.js → 6973.js} +5 -5
  31. package/dist/721.js +9 -0
  32. package/dist/9131.js +559 -502
  33. package/dist/browser-runtime/2~907.js +1211 -0
  34. package/dist/browser-runtime/2~907.js.map +1 -0
  35. package/dist/browser-runtime/389.js +22071 -0
  36. package/dist/browser-runtime/389.js.LICENSE.txt +329 -0
  37. package/dist/browser-runtime/389.js.map +1 -0
  38. package/dist/browser-runtime/index.d.ts +2806 -0
  39. package/dist/browser-runtime/index.js +1 -0
  40. package/dist/browser-runtime/rslib-runtime.js +50 -0
  41. package/dist/browser-runtime/rslib-runtime.js.map +1 -0
  42. package/dist/browser.d.ts +3329 -0
  43. package/dist/browser.js +14 -0
  44. package/dist/cssFilterLoader.mjs +1 -1
  45. package/dist/globalSetupWorker.js +3 -2
  46. package/dist/index.d.ts +67 -2
  47. package/dist/index.js +2 -1
  48. package/dist/rslib-runtime.js +27 -0
  49. package/dist/rstestSuppressWarnings.cjs +9 -0
  50. package/dist/worker.d.ts +66 -2
  51. package/dist/worker.js +415 -1
  52. package/package.json +29 -14
  53. package/dist/0~8957.js +0 -149
  54. package/dist/554.js +0 -417
  55. package/dist/5693.js +0 -91
  56. /package/dist/{7913.js.LICENSE.txt → 1294.js.LICENSE.txt} +0 -0
  57. /package/dist/{0~6151.js.LICENSE.txt → 6151.js.LICENSE.txt} +0 -0
package/dist/554.js DELETED
@@ -1,417 +0,0 @@
1
- import __rslib_shim_module__ from 'module';
2
- const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
3
- import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./5693.js";
5
- import { formatTestError, setRealTimers, getRealTimers } from "./7913.js";
6
- import { node_v8, createBirpc } from "./3216.js";
7
- import { basename, isAbsolute, dirname, resolve as pathe_M_eThtNZ_resolve, join } from "./3278.js";
8
- import { createCoverageProvider } from "./5734.js";
9
- import { undoSerializableConfig, globalApis } from "./1157.js";
10
- __webpack_require__.add({
11
- timers (module) {
12
- module.exports = require("timers");
13
- },
14
- "timers/promises" (module) {
15
- module.exports = require("timers/promises");
16
- }
17
- });
18
- const processSend = process.send.bind(process);
19
- const processOn = process.on.bind(process);
20
- const processOff = process.off.bind(process);
21
- const dispose = [];
22
- function createForksRpcOptions(nodeV8 = node_v8) {
23
- return {
24
- serialize: nodeV8.serialize,
25
- deserialize: (v)=>nodeV8.deserialize(Buffer.from(v)),
26
- post (v) {
27
- processSend(v);
28
- },
29
- on (fn) {
30
- const handler = (message, ...extras)=>{
31
- if (message?.__tinypool_worker_message__) return;
32
- return fn(message, ...extras);
33
- };
34
- processOn('message', handler);
35
- dispose.push(()=>processOff('message', handler));
36
- }
37
- };
38
- }
39
- function createRuntimeRpc(options, { originalConsole }) {
40
- const rpc = createBirpc({}, {
41
- ...options,
42
- onTimeoutError: (functionName, error)=>{
43
- switch(functionName){
44
- case 'onTestCaseStart':
45
- {
46
- const caseTest = error[0];
47
- console.error(`[Rstest] timeout on calling "onTestCaseStart" rpc method (Case: "${caseTest.name}")`);
48
- return true;
49
- }
50
- case 'onTestCaseResult':
51
- {
52
- const caseResult = error[0];
53
- console.error(`[Rstest] timeout on calling "onTestCaseResult" rpc method (Case: "${caseResult.name}", Result: "${caseResult.status}")`);
54
- return true;
55
- }
56
- case 'onConsoleLog':
57
- originalConsole.error(`[Rstest] timeout on calling "onConsoleLog" rpc method (Original log: ${error[0].content})`);
58
- return true;
59
- default:
60
- return false;
61
- }
62
- }
63
- });
64
- return {
65
- rpc
66
- };
67
- }
68
- const external_node_fs_ = __webpack_require__("node:fs");
69
- class NodeSnapshotEnvironment {
70
- constructor(options = {}){
71
- this.options = options;
72
- }
73
- getVersion() {
74
- return "1";
75
- }
76
- getHeader() {
77
- return `// Snapshot v${this.getVersion()}`;
78
- }
79
- async resolveRawPath(testPath, rawPath) {
80
- return isAbsolute(rawPath) ? rawPath : pathe_M_eThtNZ_resolve(dirname(testPath), rawPath);
81
- }
82
- async resolvePath(filepath) {
83
- return join(join(dirname(filepath), this.options.snapshotsDirName ?? "__snapshots__"), `${basename(filepath)}.snap`);
84
- }
85
- async prepareDirectory(dirPath) {
86
- await external_node_fs_.promises.mkdir(dirPath, {
87
- recursive: true
88
- });
89
- }
90
- async saveSnapshotFile(filepath, snapshot) {
91
- await external_node_fs_.promises.mkdir(dirname(filepath), {
92
- recursive: true
93
- });
94
- await external_node_fs_.promises.writeFile(filepath, snapshot, "utf-8");
95
- }
96
- async readSnapshotFile(filepath) {
97
- if (!(0, external_node_fs_.existsSync)(filepath)) return null;
98
- return external_node_fs_.promises.readFile(filepath, "utf-8");
99
- }
100
- async removeSnapshotFile(filepath) {
101
- if ((0, external_node_fs_.existsSync)(filepath)) await external_node_fs_.promises.unlink(filepath);
102
- }
103
- }
104
- class RstestSnapshotEnvironment extends NodeSnapshotEnvironment {
105
- resolveSnapshotPath;
106
- constructor(options){
107
- super();
108
- this.resolveSnapshotPath = options.resolveSnapshotPath;
109
- }
110
- getHeader() {
111
- return `// Rstest Snapshot v${this.getVersion()}`;
112
- }
113
- resolvePath(filepath) {
114
- return this.resolveSnapshotPath(filepath);
115
- }
116
- }
117
- const source_map_support = __webpack_require__("../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js");
118
- const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
119
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
120
- let sourceMaps = {};
121
- (0, source_map_support.install)({
122
- environment: 'node',
123
- handleUncaughtExceptions: false,
124
- retrieveSourceMap: (source)=>{
125
- if (sourceMaps[source]) return {
126
- url: source,
127
- map: JSON.parse(sourceMaps[source])
128
- };
129
- return null;
130
- }
131
- });
132
- const registerGlobalApi = (api)=>globalApis.reduce((apis, key)=>{
133
- globalThis[key] = api[key];
134
- return apis;
135
- }, {});
136
- const listeners = [];
137
- let isTeardown = false;
138
- const setupEnv = (env)=>{
139
- if (env) Object.assign(process.env, env);
140
- };
141
- const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot, context })=>{
142
- setRealTimers();
143
- context.runtimeConfig = undoSerializableConfig(context.runtimeConfig);
144
- process.env.RSTEST_WORKER_ID = String(process.__tinypool_state__.workerId || context.taskId);
145
- const cleanupFns = [];
146
- const originalConsole = global.console;
147
- const { rpc } = createRuntimeRpc(createForksRpcOptions(), {
148
- originalConsole
149
- });
150
- const { runtimeConfig: { globals, printConsoleTrace, disableConsoleIntercept, testEnvironment, snapshotFormat, env } } = context;
151
- setupEnv(env);
152
- if (!disableConsoleIntercept) {
153
- const { createCustomConsole } = await import("./0~130.js").then((mod)=>({
154
- createCustomConsole: mod.createCustomConsole
155
- }));
156
- global.console = createCustomConsole({
157
- rpc,
158
- testPath,
159
- printConsoleTrace
160
- });
161
- }
162
- const interopDefault = true;
163
- const workerState = {
164
- ...context,
165
- snapshotOptions: {
166
- updateSnapshot,
167
- snapshotEnvironment: new RstestSnapshotEnvironment({
168
- resolveSnapshotPath: (filepath)=>rpc.resolveSnapshotPath(filepath)
169
- }),
170
- snapshotFormat
171
- },
172
- distPath,
173
- testPath,
174
- environment: 'node'
175
- };
176
- const { createRstestRuntime } = await import("./0~6151.js").then((mod)=>({
177
- createRstestRuntime: mod.createRstestRuntime
178
- }));
179
- listeners.forEach((fn)=>{
180
- fn();
181
- });
182
- listeners.length = 0;
183
- const unhandledErrors = [];
184
- const handleError = (e, type)=>{
185
- const error = 'string' == typeof e ? new Error(e) : e;
186
- error.name = type;
187
- if (isTeardown) {
188
- error.stack = `${picocolors_default().yellow('Caught error after test environment was torn down:')}\n\n${error.stack}`;
189
- console.error(error);
190
- } else {
191
- console.error(error);
192
- unhandledErrors.push(error);
193
- }
194
- };
195
- const uncaughtException = (e)=>handleError(e, 'uncaughtException');
196
- const unhandledRejection = (e)=>handleError(e, 'unhandledRejection');
197
- process.on('uncaughtException', uncaughtException);
198
- process.on('unhandledRejection', unhandledRejection);
199
- listeners.push(()=>{
200
- process.off('uncaughtException', uncaughtException);
201
- process.off('unhandledRejection', unhandledRejection);
202
- });
203
- const { api, runner } = await createRstestRuntime(workerState);
204
- switch(testEnvironment){
205
- case 'node':
206
- break;
207
- case 'jsdom':
208
- {
209
- const { environment } = await import("./0~62.js").then((mod)=>({
210
- environment: mod.environment
211
- }));
212
- const { teardown } = await environment.setup(global, {});
213
- cleanupFns.push(()=>teardown(global));
214
- break;
215
- }
216
- case 'happy-dom':
217
- {
218
- const { environment } = await import("./0~4809.js").then((mod)=>({
219
- environment: mod.environment
220
- }));
221
- const { teardown } = await environment.setup(global, {});
222
- cleanupFns.push(async ()=>teardown(global));
223
- break;
224
- }
225
- default:
226
- throw new Error(`Unknown test environment: ${testEnvironment}`);
227
- }
228
- if (globals) registerGlobalApi(api);
229
- const rstestContext = {
230
- global,
231
- console: global.console,
232
- Error
233
- };
234
- rstestContext.global['@rstest/core'] = api;
235
- return {
236
- interopDefault,
237
- rstestContext,
238
- runner,
239
- rpc,
240
- api,
241
- unhandledErrors,
242
- cleanup: async ()=>{
243
- await Promise.all(cleanupFns.map((fn)=>fn()));
244
- }
245
- };
246
- };
247
- const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault, isolate, outputModule })=>{
248
- const { loadModule, updateLatestAssetFiles } = outputModule ? await import("./0~6923.js").then((mod)=>({
249
- EsmMode: mod.loadEsModule_EsmMode,
250
- asModule: mod.asModule,
251
- loadModule: mod.loadModule,
252
- updateLatestAssetFiles: mod.updateLatestAssetFiles
253
- })) : await import("./0~5835.js").then((mod)=>({
254
- cacheableLoadModule: mod.cacheableLoadModule,
255
- loadModule: mod.loadModule,
256
- updateLatestAssetFiles: mod.updateLatestAssetFiles
257
- }));
258
- if (!isolate) {
259
- updateLatestAssetFiles(assetFiles);
260
- await loadModule({
261
- codeContent: `if (global && typeof global.__rstest_clean_core_cache__ === 'function') {
262
- global.__rstest_clean_core_cache__();
263
- }`,
264
- distPath: '',
265
- testPath,
266
- rstestContext,
267
- assetFiles,
268
- interopDefault
269
- });
270
- }
271
- for (const { distPath, testPath } of setupEntries){
272
- const setupCodeContent = assetFiles[distPath];
273
- await loadModule({
274
- codeContent: setupCodeContent,
275
- distPath,
276
- testPath,
277
- rstestContext,
278
- assetFiles,
279
- interopDefault
280
- });
281
- }
282
- await loadModule({
283
- codeContent: assetFiles[distPath],
284
- distPath,
285
- testPath,
286
- rstestContext,
287
- assetFiles,
288
- interopDefault
289
- });
290
- };
291
- const runInPool = async (options)=>{
292
- isTeardown = false;
293
- const { entryInfo: { distPath, testPath }, setupEntries, assets, type, context: { project, runtimeConfig: { isolate, bail } } } = options;
294
- const cleanups = [];
295
- const exit = process.exit.bind(process);
296
- process.exit = (code = process.exitCode || 0)=>{
297
- throw new Error(`process.exit unexpectedly called with "${code}"`);
298
- };
299
- const kill = process.kill.bind(process);
300
- process.kill = (pid, signal)=>{
301
- if (-1 === pid || Math.abs(pid) === process.pid) throw new Error(`process.kill unexpectedly called with "${pid}" and "${signal}"`);
302
- return kill(pid, signal);
303
- };
304
- cleanups.push(()=>{
305
- process.kill = kill;
306
- process.exit = exit;
307
- });
308
- const teardown = async ()=>{
309
- await new Promise((resolve)=>getRealTimers().setTimeout(resolve));
310
- await Promise.all(cleanups.map((fn)=>fn()));
311
- isTeardown = true;
312
- };
313
- if ('collect' === type) try {
314
- const { rstestContext, runner, rpc, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
315
- const { assetFiles, sourceMaps: sourceMapsFromAssets } = assets || await rpc.getAssetsByEntry();
316
- sourceMaps = sourceMapsFromAssets;
317
- cleanups.push(cleanup);
318
- await loadFiles({
319
- rstestContext,
320
- distPath,
321
- testPath,
322
- assetFiles,
323
- setupEntries,
324
- interopDefault,
325
- isolate,
326
- outputModule: options.context.outputModule
327
- });
328
- const tests = await runner.collectTests();
329
- return {
330
- project,
331
- testPath,
332
- tests,
333
- errors: formatTestError(unhandledErrors)
334
- };
335
- } catch (err) {
336
- return {
337
- project,
338
- testPath,
339
- tests: [],
340
- errors: formatTestError(err)
341
- };
342
- } finally{
343
- await teardown();
344
- }
345
- try {
346
- const { rstestContext, runner, rpc, api, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
347
- if (bail && await rpc.getCountOfFailedTests() >= bail) return {
348
- testId: '0',
349
- project,
350
- testPath,
351
- status: 'skip',
352
- name: '',
353
- results: []
354
- };
355
- const coverageProvider = await createCoverageProvider(options.context.runtimeConfig.coverage || {}, options.context.rootPath);
356
- if (coverageProvider) coverageProvider.init();
357
- const { assetFiles, sourceMaps: sourceMapsFromAssets } = assets || await rpc.getAssetsByEntry();
358
- sourceMaps = sourceMapsFromAssets;
359
- cleanups.push(cleanup);
360
- rpc.onTestFileStart?.({
361
- testPath,
362
- tests: []
363
- });
364
- await loadFiles({
365
- rstestContext,
366
- distPath,
367
- testPath,
368
- assetFiles,
369
- setupEntries,
370
- interopDefault,
371
- isolate,
372
- outputModule: options.context.outputModule
373
- });
374
- const results = await runner.runTests(testPath, {
375
- onTestFileReady: async (test)=>{
376
- await rpc.onTestFileReady(test);
377
- },
378
- onTestSuiteStart: async (test)=>{
379
- await rpc.onTestSuiteStart(test);
380
- },
381
- onTestSuiteResult: async (result)=>{
382
- await rpc.onTestSuiteResult(result);
383
- },
384
- onTestCaseStart: async (test)=>{
385
- await rpc.onTestCaseStart(test);
386
- },
387
- onTestCaseResult: async (result)=>{
388
- await rpc.onTestCaseResult(result);
389
- },
390
- getCountOfFailedTests: async ()=>rpc.getCountOfFailedTests()
391
- }, api);
392
- if (unhandledErrors.length > 0) {
393
- results.status = 'fail';
394
- results.errors = (results.errors || []).concat(...formatTestError(unhandledErrors));
395
- }
396
- if (coverageProvider) {
397
- const coverageMap = coverageProvider.collect();
398
- if (coverageMap) results.coverage = coverageMap.toJSON();
399
- coverageProvider.cleanup();
400
- }
401
- return results;
402
- } catch (err) {
403
- return {
404
- testId: '0',
405
- project,
406
- testPath,
407
- status: 'fail',
408
- name: '',
409
- results: [],
410
- errors: formatTestError(err)
411
- };
412
- } finally{
413
- await teardown();
414
- }
415
- };
416
- const worker = runInPool;
417
- export default worker;
package/dist/5693.js DELETED
@@ -1,91 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
4
- import * as __rspack_external_node_os_74b4b876 from "node:os";
5
- import * as __rspack_external_node_path_c5b9b54f from "node:path";
6
- import * as __rspack_external_node_tty_c64aab7e from "node:tty";
7
- import * as __rspack_external_node_util_1b29d436 from "node:util";
8
- import { __webpack_require__ } from "./rslib-runtime.js";
9
- __webpack_require__.add({
10
- "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) {
11
- let p = process || {}, argv = p.argv || [], env = p.env || {};
12
- let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
13
- let formatter = (open, close, replace = open)=>(input)=>{
14
- let string = "" + input, index = string.indexOf(close, open.length);
15
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
16
- };
17
- let replaceClose = (string, close, replace, index)=>{
18
- let result = "", cursor = 0;
19
- do {
20
- result += string.substring(cursor, index) + replace;
21
- cursor = index + close.length;
22
- index = string.indexOf(close, cursor);
23
- }while (~index);
24
- return result + string.substring(cursor);
25
- };
26
- let createColors = (enabled = isColorSupported)=>{
27
- let f = enabled ? formatter : ()=>String;
28
- return {
29
- isColorSupported: enabled,
30
- reset: f("\x1b[0m", "\x1b[0m"),
31
- bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
32
- dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
33
- italic: f("\x1b[3m", "\x1b[23m"),
34
- underline: f("\x1b[4m", "\x1b[24m"),
35
- inverse: f("\x1b[7m", "\x1b[27m"),
36
- hidden: f("\x1b[8m", "\x1b[28m"),
37
- strikethrough: f("\x1b[9m", "\x1b[29m"),
38
- black: f("\x1b[30m", "\x1b[39m"),
39
- red: f("\x1b[31m", "\x1b[39m"),
40
- green: f("\x1b[32m", "\x1b[39m"),
41
- yellow: f("\x1b[33m", "\x1b[39m"),
42
- blue: f("\x1b[34m", "\x1b[39m"),
43
- magenta: f("\x1b[35m", "\x1b[39m"),
44
- cyan: f("\x1b[36m", "\x1b[39m"),
45
- white: f("\x1b[37m", "\x1b[39m"),
46
- gray: f("\x1b[90m", "\x1b[39m"),
47
- bgBlack: f("\x1b[40m", "\x1b[49m"),
48
- bgRed: f("\x1b[41m", "\x1b[49m"),
49
- bgGreen: f("\x1b[42m", "\x1b[49m"),
50
- bgYellow: f("\x1b[43m", "\x1b[49m"),
51
- bgBlue: f("\x1b[44m", "\x1b[49m"),
52
- bgMagenta: f("\x1b[45m", "\x1b[49m"),
53
- bgCyan: f("\x1b[46m", "\x1b[49m"),
54
- bgWhite: f("\x1b[47m", "\x1b[49m"),
55
- blackBright: f("\x1b[90m", "\x1b[39m"),
56
- redBright: f("\x1b[91m", "\x1b[39m"),
57
- greenBright: f("\x1b[92m", "\x1b[39m"),
58
- yellowBright: f("\x1b[93m", "\x1b[39m"),
59
- blueBright: f("\x1b[94m", "\x1b[39m"),
60
- magentaBright: f("\x1b[95m", "\x1b[39m"),
61
- cyanBright: f("\x1b[96m", "\x1b[39m"),
62
- whiteBright: f("\x1b[97m", "\x1b[39m"),
63
- bgBlackBright: f("\x1b[100m", "\x1b[49m"),
64
- bgRedBright: f("\x1b[101m", "\x1b[49m"),
65
- bgGreenBright: f("\x1b[102m", "\x1b[49m"),
66
- bgYellowBright: f("\x1b[103m", "\x1b[49m"),
67
- bgBlueBright: f("\x1b[104m", "\x1b[49m"),
68
- bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
69
- bgCyanBright: f("\x1b[106m", "\x1b[49m"),
70
- bgWhiteBright: f("\x1b[107m", "\x1b[49m")
71
- };
72
- };
73
- module.exports = createColors();
74
- module.exports.createColors = createColors;
75
- },
76
- "node:fs" (module) {
77
- module.exports = __rspack_external_node_fs_5ea92f0c;
78
- },
79
- "node:os" (module) {
80
- module.exports = __rspack_external_node_os_74b4b876;
81
- },
82
- "node:path" (module) {
83
- module.exports = __rspack_external_node_path_c5b9b54f;
84
- },
85
- "node:tty" (module) {
86
- module.exports = __rspack_external_node_tty_c64aab7e;
87
- },
88
- "node:util" (module) {
89
- module.exports = __rspack_external_node_util_1b29d436;
90
- }
91
- });