@rstest/core 0.6.5 → 0.6.7

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.
@@ -4,9 +4,9 @@ import { __webpack_require__ } from "./rslib-runtime.js";
4
4
  import node_events from "node:events";
5
5
  import { Tinypool } from "tinypool";
6
6
  import node_inspector from "node:inspector";
7
- import { basename, TEMP_RSTEST_OUTPUT_DIR, dirname, posix, resolve as pathe_M_eThtNZ_resolve, serializableConfig, node_process, isBuiltin, castArray, TEMP_RSTEST_OUTPUT_DIR_GLOB, isDebug, ADDITIONAL_NODE_BUILTINS, join, needFlagExperimentalDetectModule } from "./857.js";
8
- import { node_v8, fileURLToPath, createBirpc } from "./808.js";
9
- import { logger, createRsbuild } from "./index.js";
7
+ import { basename, TEMP_RSTEST_OUTPUT_DIR, dirname, posix, resolve as pathe_M_eThtNZ_resolve, serializableConfig, node_process, isBuiltin, castArray, TEMP_RSTEST_OUTPUT_DIR_GLOB, isDebug, ADDITIONAL_NODE_BUILTINS, join, needFlagExperimentalDetectModule } from "./946.js";
8
+ import { node_v8, fileURLToPath, createBirpc } from "./770.js";
9
+ import { logger, createRsbuild } from "./155.js";
10
10
  const DefaultMaxHeapSize = 1073741824;
11
11
  function memory_isMemorySufficient(options) {
12
12
  const { memoryThreshold = 0.7, maxHeapSize = DefaultMaxHeapSize } = options || {};
@@ -167,6 +167,9 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
167
167
  }
168
168
  });
169
169
  const rpcMethods = {
170
+ onTestCaseStart: async (test)=>{
171
+ Promise.all(reporters.map((reporter)=>reporter.onTestCaseStart?.(test)));
172
+ },
170
173
  onTestCaseResult: async (result)=>{
171
174
  context.stateManager.onTestCaseResult(result);
172
175
  await Promise.all(reporters.map((reporter)=>reporter.onTestCaseResult?.(result)));
@@ -214,6 +217,7 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
214
217
  }).catch((err)=>{
215
218
  err.fullStack = true;
216
219
  return {
220
+ testId: '0',
217
221
  project: projectName,
218
222
  testPath: entryInfo.testPath,
219
223
  status: 'fail',
@@ -324,7 +328,8 @@ const pluginBasic = (context)=>({
324
328
  requireDynamic: false,
325
329
  requireAsExpression: false,
326
330
  requireResolve: false,
327
- ...config.module.parser.javascript || {}
331
+ ...config.module.parser.javascript || {},
332
+ exportsPresence: 'warn'
328
333
  };
329
334
  config.resolve ??= {};
330
335
  config.resolve.extensions ??= [];
@@ -441,7 +446,7 @@ const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context
441
446
  });
442
447
  const autoExternalNodeModules = ({ context, request, dependencyType, getResolve }, callback)=>{
443
448
  if (!request) return callback();
444
- if (request.startsWith('@swc/helpers/')) return callback();
449
+ if (request.startsWith('@swc/helpers/') || request.endsWith('.wasm')) return callback();
445
450
  const doExternal = (externalPath = request)=>{
446
451
  callback(void 0, externalPath, 'commonjs' === dependencyType ? 'commonjs' : 'import');
447
452
  };
@@ -546,6 +551,10 @@ class MockRuntimeRspackPlugin {
546
551
  const finalSource = module.source.source.toString('utf-8').replace('enumerable: true, get:', 'enumerable: true, configurable: true, get:');
547
552
  module.source.source = Buffer.from(finalSource);
548
553
  }
554
+ if ('async_wasm_loading' === module.name) {
555
+ const finalSource = module.source.source.toString('utf-8').replace('readFile(', 'readWasmFile(');
556
+ module.source.source = Buffer.from(finalSource);
557
+ }
549
558
  });
550
559
  });
551
560
  compiler.hooks.thisCompilation.tap('RstestMockPlugin', (compilation)=>{
@@ -677,10 +686,10 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
677
686
  }
678
687
  });
679
688
  if (coverage?.enabled && 'list' !== command) {
680
- const { loadCoverageProvider } = await import("./603.js").then((mod)=>({
689
+ const { loadCoverageProvider } = await import("./734.js").then((mod)=>({
681
690
  loadCoverageProvider: mod.loadCoverageProvider
682
691
  }));
683
- const { pluginCoverageCore } = await import("./0~836.js").then((mod)=>({
692
+ const { pluginCoverageCore } = await import("./0~255.js").then((mod)=>({
684
693
  pluginCoverageCore: mod.pluginCoverageCore
685
694
  }));
686
695
  const { pluginCoverage } = await loadCoverageProvider(coverage, context.rootPath);
@@ -3,7 +3,7 @@ import 'module';
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
4
  import { AssertionError, strict } from "node:assert";
5
5
  import { Console } from "node:console";
6
- import { prettyTime } from "./857.js";
6
+ import { prettyTime } from "./946.js";
7
7
  const external_node_util_ = __webpack_require__("node:util");
8
8
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
9
9
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
@@ -1,9 +1,9 @@
1
- /*! For license information please see 0~764.js.LICENSE.txt */
1
+ /*! For license information please see 0~151.js.LICENSE.txt */
2
2
  import 'module';
3
3
  /*#__PURE__*/ import.meta.url;
4
4
  import { __webpack_require__ } from "./rslib-runtime.js";
5
- import { getTaskNameWithPrefix, isObject as helper_isObject, castArray, resolve as pathe_M_eThtNZ_resolve, ROOT_SUITE_NAME } from "./857.js";
6
- import { getRealTimers, TestRegisterError, formatTestError, formatName } from "./worker.js";
5
+ import { getTaskNameWithPrefix, isObject as helper_isObject, castArray, resolve as pathe_M_eThtNZ_resolve, ROOT_SUITE_NAME } from "./946.js";
6
+ import { getRealTimers, TestRegisterError, formatTestError, formatName } from "./362.js";
7
7
  __webpack_require__.add({
8
8
  "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js": function(module, __unused_webpack_exports, __webpack_require__) {
9
9
  var every = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").every;
@@ -10896,7 +10896,7 @@ function offsetToLineNumber(source, offset) {
10896
10896
  return line + 1;
10897
10897
  }
10898
10898
  async function saveInlineSnapshots(environment, snapshots) {
10899
- const MagicString = (await import("./0~830.js").then((mod)=>({
10899
+ const MagicString = (await import("./0~454.js").then((mod)=>({
10900
10900
  Bundle: mod.Bundle,
10901
10901
  SourceMap: mod.SourceMap,
10902
10902
  default: mod.MagicString
@@ -11646,7 +11646,8 @@ function getError(expected, promise) {
11646
11646
  function getTestNames(test) {
11647
11647
  return {
11648
11648
  filepath: test.testPath,
11649
- name: getTaskNameWithPrefix(test)
11649
+ name: getTaskNameWithPrefix(test),
11650
+ testId: test.testId
11650
11651
  };
11651
11652
  }
11652
11653
  const SnapshotPlugin = (chai, utils)=>{
@@ -12094,6 +12095,7 @@ class TestRunner {
12094
12095
  if ('skip' === test.runMode) {
12095
12096
  snapshotClient.skipTest(testPath, getTaskNameWithPrefix(test));
12096
12097
  const result = {
12098
+ testId: test.testId,
12097
12099
  status: 'skip',
12098
12100
  parentNames: test.parentNames,
12099
12101
  name: test.name,
@@ -12104,6 +12106,7 @@ class TestRunner {
12104
12106
  }
12105
12107
  if ('todo' === test.runMode) {
12106
12108
  const result = {
12109
+ testId: test.testId,
12107
12110
  status: 'todo',
12108
12111
  parentNames: test.parentNames,
12109
12112
  name: test.name,
@@ -12122,6 +12125,7 @@ class TestRunner {
12122
12125
  }
12123
12126
  } catch (error) {
12124
12127
  result = {
12128
+ testId: test.testId,
12125
12129
  status: 'fail',
12126
12130
  parentNames: test.parentNames,
12127
12131
  name: test.name,
@@ -12136,6 +12140,7 @@ class TestRunner {
12136
12140
  await test.fn?.(test.context);
12137
12141
  this.afterRunTest(test);
12138
12142
  result = {
12143
+ testId: test.testId,
12139
12144
  status: 'fail',
12140
12145
  parentNames: test.parentNames,
12141
12146
  name: test.name,
@@ -12149,6 +12154,7 @@ class TestRunner {
12149
12154
  };
12150
12155
  } catch (_err) {
12151
12156
  result = {
12157
+ testId: test.testId,
12152
12158
  project,
12153
12159
  status: 'pass',
12154
12160
  parentNames: test.parentNames,
@@ -12162,6 +12168,7 @@ class TestRunner {
12162
12168
  await test.fn?.(test.context);
12163
12169
  this.afterRunTest(test);
12164
12170
  result = {
12171
+ testId: test.testId,
12165
12172
  project,
12166
12173
  parentNames: test.parentNames,
12167
12174
  name: test.name,
@@ -12170,6 +12177,7 @@ class TestRunner {
12170
12177
  };
12171
12178
  } catch (error) {
12172
12179
  result = {
12180
+ testId: test.testId,
12173
12181
  project,
12174
12182
  status: 'fail',
12175
12183
  parentNames: test.parentNames,
@@ -12249,6 +12257,7 @@ class TestRunner {
12249
12257
  };
12250
12258
  errors.push(noTestError);
12251
12259
  const result = {
12260
+ testId: test.testId || '0',
12252
12261
  status: 'fail',
12253
12262
  parentNames: test.parentNames,
12254
12263
  name: test.name,
@@ -12298,6 +12307,15 @@ class TestRunner {
12298
12307
  const start = RealDate.now();
12299
12308
  let result;
12300
12309
  let retryCount = 0;
12310
+ hooks.onTestCaseStart?.({
12311
+ testId: test.testId,
12312
+ startTime: start,
12313
+ testPath: test.testPath,
12314
+ name: test.name,
12315
+ timeout: test.timeout,
12316
+ parentNames: test.parentNames,
12317
+ project: test.project
12318
+ });
12301
12319
  do {
12302
12320
  const currentResult = await runTestsCase(test, parentHooks);
12303
12321
  result = {
@@ -12316,6 +12334,7 @@ class TestRunner {
12316
12334
  const start = RealDate.now();
12317
12335
  if (0 === tests.length) {
12318
12336
  if (passWithNoTests) return {
12337
+ testId: '0',
12319
12338
  project,
12320
12339
  testPath,
12321
12340
  name: '',
@@ -12323,6 +12342,7 @@ class TestRunner {
12323
12342
  results
12324
12343
  };
12325
12344
  return {
12345
+ testId: '0',
12326
12346
  project,
12327
12347
  testPath,
12328
12348
  name: '',
@@ -12343,6 +12363,7 @@ class TestRunner {
12343
12363
  });
12344
12364
  const snapshotResult = await snapshotClient.finish(testPath);
12345
12365
  return {
12366
+ testId: '0',
12346
12367
  project,
12347
12368
  testPath,
12348
12369
  name: '',
@@ -12458,6 +12479,7 @@ class RunnerRuntime {
12458
12479
  currentCollectList = [];
12459
12480
  runtimeConfig;
12460
12481
  project;
12482
+ testId = 1;
12461
12483
  constructor({ testPath, runtimeConfig, project }){
12462
12484
  this.project = project;
12463
12485
  this.testPath = testPath;
@@ -12548,7 +12570,11 @@ class RunnerRuntime {
12548
12570
  resetCurrentTest() {
12549
12571
  this._currentTest.pop();
12550
12572
  }
12551
- addTest(test) {
12573
+ addTest(testInfo) {
12574
+ const test = {
12575
+ ...testInfo,
12576
+ testId: `${this.testId++}`
12577
+ };
12552
12578
  if (0 === this._currentTest.length) this.tests.push(test);
12553
12579
  else {
12554
12580
  const current = this._currentTest[this._currentTest.length - 1];
@@ -13166,6 +13192,18 @@ const createRstestUtilities = (workerState)=>{
13166
13192
  };
13167
13193
  Object.assign(workerState.runtimeConfig, config);
13168
13194
  },
13195
+ getConfig: ()=>{
13196
+ const { testTimeout, hookTimeout, clearMocks, resetMocks, restoreMocks, maxConcurrency, retry } = workerState.runtimeConfig;
13197
+ return {
13198
+ testTimeout,
13199
+ hookTimeout,
13200
+ clearMocks,
13201
+ resetMocks,
13202
+ restoreMocks,
13203
+ maxConcurrency,
13204
+ retry
13205
+ };
13206
+ },
13169
13207
  resetConfig: ()=>{
13170
13208
  if (originalConfig) Object.assign(workerState.runtimeConfig, originalConfig);
13171
13209
  },
@@ -1,9 +1,9 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import { getTestEntries, getSetupFiles, isTTY, clearScreen, src_logger } from "./857.js";
5
- import { createCoverageProvider } from "./603.js";
6
- import { prepareRsbuild, createPool, createRsbuildServer } from "./0~814.js";
4
+ import { getTestEntries, getSetupFiles, isTTY, clearScreen, src_logger } from "./946.js";
5
+ import { createCoverageProvider } from "./734.js";
6
+ import { prepareRsbuild, createPool, createRsbuildServer } from "./0~122.js";
7
7
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
8
8
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
9
9
  const isCliShortcutsEnabled = ()=>isTTY('stdin');
@@ -275,11 +275,15 @@ async function runTests(context) {
275
275
  filterRerunTestPaths: currentEntries.length ? currentEntries.map((e)=>e.testPath) : void 0
276
276
  });
277
277
  if (coverageProvider && (!isFailure || coverage.reportOnFailure)) {
278
- const { generateCoverage } = await import("./0~204.js").then((mod)=>({
278
+ const { generateCoverage } = await import("./0~403.js").then((mod)=>({
279
279
  generateCoverage: mod.generateCoverage
280
280
  }));
281
281
  await generateCoverage(context, results, coverageProvider);
282
282
  }
283
+ if (isFailure) {
284
+ const bail = context.normalizedConfig.bail;
285
+ if (bail && context.stateManager.getCountOfFailedTests() >= bail) src_logger.log(picocolors_default().yellow(`Test run aborted due to reaching the bail limit of ${bail} failed test(s).`));
286
+ }
283
287
  };
284
288
  if ('watch' === command) {
285
289
  const enableCliShortcuts = isCliShortcutsEnabled();
@@ -288,7 +292,7 @@ async function runTests(context) {
288
292
  if (enableCliShortcuts) if (snapshotManager.summary.unmatched) src_logger.log(` ${picocolors_default().dim('press')} ${picocolors_default().yellow(picocolors_default().bold('u'))} ${picocolors_default().dim('to update snapshot')}${picocolors_default().dim(', press')} ${picocolors_default().bold('h')} ${picocolors_default().dim('to show help')}\n`);
289
293
  else src_logger.log(` ${picocolors_default().dim('press')} ${picocolors_default().bold('h')} ${picocolors_default().dim('to show help')}${picocolors_default().dim(', press')} ${picocolors_default().bold('q')} ${picocolors_default().dim('to quit')}\n`);
290
294
  };
291
- const { onBeforeRestart } = await import("./0~365.js").then((mod)=>({
295
+ const { onBeforeRestart } = await import("./0~588.js").then((mod)=>({
292
296
  onBeforeRestart: mod.onBeforeRestart
293
297
  }));
294
298
  onBeforeRestart(async ()=>{
@@ -1,7 +1,7 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./857.js";
4
+ import "./946.js";
5
5
  const external_node_fs_ = __webpack_require__("node:fs");
6
6
  const pluginCoverageCore = (coverageOptions)=>({
7
7
  name: 'rstest:coverage-core',
@@ -1,6 +1,6 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import { isDynamicPattern, glob, normalize, src_logger } from "./857.js";
3
+ import { isDynamicPattern, glob, normalize, src_logger } from "./946.js";
4
4
  const getIncludedFiles = async (coverage, rootPath)=>{
5
5
  const ignoredPatterns = coverage.exclude?.filter((item)=>isDynamicPattern(item) || item.startsWith(rootPath) || item.startsWith('./'));
6
6
  const allFiles = await glob(coverage.include, {
@@ -41,7 +41,7 @@ async function generateCoverage(context, results, coverageProvider) {
41
41
  }
42
42
  await coverageProvider.generateReports(finalCoverageMap, coverage);
43
43
  if (coverage.thresholds) {
44
- const { checkThresholds } = await import("./0~691.js").then((mod)=>({
44
+ const { checkThresholds } = await import("./0~426.js").then((mod)=>({
45
45
  checkThresholds: mod.checkThresholds
46
46
  }));
47
47
  const thresholdResult = checkThresholds({
@@ -1,7 +1,7 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import { pathe_M_eThtNZ_relative } from "./857.js";
4
+ import { pathe_M_eThtNZ_relative } from "./946.js";
5
5
  const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
6
6
  var picomatch_default = /*#__PURE__*/ __webpack_require__.n(picomatch);
7
7
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,6 +1,6 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import { encode } from "./597.js";
3
+ import { encode } from "./397.js";
4
4
  class BitSet {
5
5
  constructor(arg){
6
6
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
@@ -1,11 +1,11 @@
1
- /*! For license information please see 0~263.js.LICENSE.txt */
1
+ /*! For license information please see 0~583.js.LICENSE.txt */
2
2
  import 'module';
3
3
  /*#__PURE__*/ import.meta.url;
4
4
  import { __webpack_require__ } from "./rslib-runtime.js";
5
5
  import { lstat, open as promises_open, readdir, realpath as promises_realpath, stat as promises_stat } from "fs/promises";
6
6
  import { Readable } from "node:stream";
7
- import { readdir as promises_readdir, lstat as promises_lstat, promises_stat as promises_promises_stat, realpath as external_node_fs_promises_realpath } from "./857.js";
8
- import { EventEmitter } from "./index.js";
7
+ import { readdir as promises_readdir, lstat as promises_lstat, promises_stat as promises_promises_stat, realpath as external_node_fs_promises_realpath } from "./946.js";
8
+ import { EventEmitter } from "./155.js";
9
9
  const external_node_path_ = __webpack_require__("node:path");
10
10
  const EntryTypes = {
11
11
  FILE_TYPE: 'files',
@@ -1,12 +1,12 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import { src_logger, isTTY } from "./857.js";
5
- import { runRest } from "./index.js";
4
+ import { src_logger, isTTY } from "./946.js";
5
+ import { runRest } from "./155.js";
6
6
  const GLOB_REGEX = /[*?{}[\]()!@+|]/;
7
7
  const isGlob = (str)=>GLOB_REGEX.test(str);
8
8
  async function createChokidar(pathOrGlobs, root, options) {
9
- const chokidar = await import("./0~263.js").then((mod)=>({
9
+ const chokidar = await import("./0~583.js").then((mod)=>({
10
10
  watch: mod.watch
11
11
  }));
12
12
  const watchFiles = new Set();
@@ -16,7 +16,7 @@ async function createChokidar(pathOrGlobs, root, options) {
16
16
  return false;
17
17
  });
18
18
  if (globPatterns.length) {
19
- const { glob } = await import("./857.js").then((mod)=>({
19
+ const { glob } = await import("./946.js").then((mod)=>({
20
20
  glob: mod.glob
21
21
  }));
22
22
  const files = await glob(globPatterns, {
@@ -1,7 +1,7 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import { checkPkgInstalled } from "./worker.js";
4
- import { installGlobal, addDefaultErrorHandler } from "./0~463.js";
3
+ import { checkPkgInstalled } from "./362.js";
4
+ import { installGlobal, addDefaultErrorHandler } from "./0~681.js";
5
5
  const environment = {
6
6
  name: 'jsdom',
7
7
  async setup (global, { jsdom = {} }) {
@@ -1,8 +1,8 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import { getTestEntries, getSetupFiles, getTaskNameWithPrefix, prettyTestPath, src_logger } from "./857.js";
5
- import { prepareRsbuild, createPool, createRsbuildServer } from "./0~814.js";
4
+ import { getTestEntries, getSetupFiles, getTaskNameWithPrefix, prettyTestPath, src_logger } from "./946.js";
5
+ import { prepareRsbuild, createPool, createRsbuildServer } from "./0~122.js";
6
6
  const external_node_fs_ = __webpack_require__("node:fs");
7
7
  const external_node_path_ = __webpack_require__("node:path");
8
8
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -122,7 +122,7 @@ async function listTests(context, { filesOnly, json }) {
122
122
  const hasError = list.some((file)=>file.errors?.length);
123
123
  const showProject = context.projects.length > 1;
124
124
  if (hasError) {
125
- const { printError } = await import("./index.js").then((mod)=>({
125
+ const { printError } = await import("./155.js").then((mod)=>({
126
126
  printError: mod.error_printError
127
127
  }));
128
128
  process.exitCode = 1;
@@ -1,7 +1,7 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import { checkPkgInstalled } from "./worker.js";
4
- import { installGlobal, addDefaultErrorHandler } from "./0~463.js";
3
+ import { checkPkgInstalled } from "./362.js";
4
+ import { installGlobal, addDefaultErrorHandler } from "./0~681.js";
5
5
  const environment = {
6
6
  name: 'happy-dom',
7
7
  async setup (global, { happyDom = {} }) {
@@ -1,7 +1,7 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./857.js";
4
+ import "./946.js";
5
5
  __webpack_require__.add({
6
6
  "../../node_modules/.pnpm/js-tokens@4.0.0/node_modules/js-tokens/index.js": function(__unused_webpack_module, exports) {
7
7
  Object.defineProperty(exports, "__esModule", {