@rstest/core 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/0~836.js CHANGED
@@ -9,7 +9,7 @@ export const __webpack_modules__ = {
9
9
  __webpack_require__.d(__webpack_exports__, {
10
10
  pluginCoverageCore: ()=>pluginCoverageCore
11
11
  });
12
- var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
12
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
13
13
  const pluginCoverageCore = (coverageOptions)=>({
14
14
  name: 'rstest:coverage-core',
15
15
  setup: (api)=>{
package/dist/0~85.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import * as __WEBPACK_EXTERNAL_MODULE_chai__ from "chai";
4
3
  export const __webpack_id__ = "85";
5
4
  export const __webpack_ids__ = [
6
5
  "85"
@@ -12,7 +11,7 @@ export const __webpack_modules__ = {
12
11
  });
13
12
  var dist = __webpack_require__("../../node_modules/.pnpm/@vitest+expect@3.2.4/node_modules/@vitest/expect/dist/index.js");
14
13
  var src_utils = __webpack_require__("./src/utils/index.ts");
15
- var external_chai_ = __webpack_require__("chai");
14
+ var node_modules_chai = __webpack_require__("../../node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js");
16
15
  var runtime_util = __webpack_require__("./src/runtime/util.ts");
17
16
  const unsupported = [
18
17
  'matchSnapshot',
@@ -33,12 +32,12 @@ export const __webpack_modules__ = {
33
32
  poll: true
34
33
  });
35
34
  fn = fn.bind(assertion);
36
- const test = external_chai_.util.flag(assertion, 'vitest-test');
35
+ const test = node_modules_chai.ZS.flag(assertion, 'vitest-test');
37
36
  if (!test) throw new Error('expect.poll() must be called inside a test');
38
37
  const proxy = new Proxy(assertion, {
39
38
  get (target, key, receiver) {
40
39
  const assertionFunction = Reflect.get(target, key, receiver);
41
- if ('function' != typeof assertionFunction) return assertionFunction instanceof external_chai_.Assertion ? proxy : assertionFunction;
40
+ if ('function' != typeof assertionFunction) return assertionFunction instanceof node_modules_chai.zo ? proxy : assertionFunction;
42
41
  if ('assert' === key) return assertionFunction;
43
42
  if ('string' == typeof key && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use rstest.waitFor() if your assertion condition is unstable.`);
44
43
  return function(...args) {
@@ -49,20 +48,20 @@ export const __webpack_modules__ = {
49
48
  let lastError;
50
49
  const check = async ()=>{
51
50
  try {
52
- external_chai_.util.flag(assertion, '_name', key);
51
+ node_modules_chai.ZS.flag(assertion, '_name', key);
53
52
  const obj = await fn();
54
- external_chai_.util.flag(assertion, 'object', obj);
53
+ node_modules_chai.ZS.flag(assertion, 'object', obj);
55
54
  resolve(await assertionFunction.call(assertion, ...args));
56
55
  clearTimeout(intervalId);
57
56
  clearTimeout(timeoutId);
58
57
  } catch (err) {
59
58
  lastError = err;
60
- if (!external_chai_.util.flag(assertion, '_isLastPollAttempt')) intervalId = (0, runtime_util.rZ)().setTimeout(check, interval);
59
+ if (!node_modules_chai.ZS.flag(assertion, '_isLastPollAttempt')) intervalId = (0, runtime_util.rZ)().setTimeout(check, interval);
61
60
  }
62
61
  };
63
62
  timeoutId = (0, runtime_util.rZ)().setTimeout(()=>{
64
63
  clearTimeout(intervalId);
65
- external_chai_.util.flag(assertion, '_isLastPollAttempt', true);
64
+ node_modules_chai.ZS.flag(assertion, '_isLastPollAttempt', true);
66
65
  const rejectWithCause = (cause)=>{
67
66
  reject(copyStackTrace(new Error(`Matcher did not succeed in ${timeout}ms`, {
68
67
  cause
@@ -76,8 +75,8 @@ export const __webpack_modules__ = {
76
75
  test.onFinished ??= [];
77
76
  test.onFinished.push(()=>{
78
77
  if (!awaited) {
79
- const negated = external_chai_.util.flag(assertion, 'negate') ? 'not.' : '';
80
- const name = external_chai_.util.flag(assertion, '_poll.element') ? 'element(locator)' : 'poll(assertion)';
78
+ const negated = node_modules_chai.ZS.flag(assertion, 'negate') ? 'not.' : '';
79
+ const name = node_modules_chai.ZS.flag(assertion, '_poll.element') ? 'element(locator)' : 'poll(assertion)';
81
80
  const assertionString = `expect.${name}.${negated}${String(key)}()`;
82
81
  const error = new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:\n\nawait ${assertionString}\n`);
83
82
  throw copyStackTrace(error, STACK_TRACE_ERROR);
@@ -300,22 +299,22 @@ export const __webpack_modules__ = {
300
299
  });
301
300
  utils.addMethod(chai.expect, 'addSnapshotSerializer', snapshot_dist.U$);
302
301
  };
303
- external_chai_.use(dist.Xs);
304
- external_chai_.use(dist.dB);
305
- external_chai_.use(SnapshotPlugin);
306
- external_chai_.use(dist.Mc);
302
+ node_modules_chai.Yx(dist.Xs);
303
+ node_modules_chai.Yx(dist.dB);
304
+ node_modules_chai.Yx(SnapshotPlugin);
305
+ node_modules_chai.Yx(dist.Mc);
307
306
  function createExpect({ getCurrentTest, workerState }) {
308
307
  const expect = (value, message)=>{
309
308
  const { assertionCalls } = (0, dist.Gu)(expect);
310
309
  (0, dist.wb)({
311
310
  assertionCalls: assertionCalls + 1
312
311
  }, expect);
313
- const assert = external_chai_.expect(value, message);
312
+ const assert = node_modules_chai.E3(value, message);
314
313
  const _test = getCurrentTest();
315
314
  if (_test) return assert.withTest(_test);
316
315
  return assert;
317
316
  };
318
- Object.assign(expect, external_chai_.expect);
317
+ Object.assign(expect, node_modules_chai.E3);
319
318
  Object.assign(expect, globalThis[dist.fs]);
320
319
  expect.getState = ()=>(0, dist.Gu)(expect);
321
320
  expect.setState = (state)=>(0, dist.wb)(state, expect);
@@ -331,14 +330,14 @@ export const __webpack_modules__ = {
331
330
  return workerState.testPath;
332
331
  }
333
332
  }, expect);
334
- expect.extend = (matchers)=>external_chai_.expect.extend(expect, matchers);
333
+ expect.extend = (matchers)=>node_modules_chai.E3.extend(expect, matchers);
335
334
  expect.addEqualityTesters = (customTesters)=>(0, dist.TB)(customTesters);
336
335
  expect.soft = (...args)=>expect(...args).withContext({
337
336
  soft: true
338
337
  });
339
338
  expect.poll = createExpectPoll(expect);
340
339
  expect.unreachable = (message)=>{
341
- external_chai_.assert.fail(`expected ${message ? `"${message}" ` : ''}not to be reached`);
340
+ node_modules_chai.vA.fail(`expected ${message ? `"${message}" ` : ''}not to be reached`);
342
341
  };
343
342
  function assertions(expected) {
344
343
  const errorGen = ()=>new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
@@ -356,8 +355,8 @@ export const __webpack_modules__ = {
356
355
  isExpectingAssertionsError: error
357
356
  });
358
357
  }
359
- external_chai_.util.addMethod(expect, 'assertions', assertions);
360
- external_chai_.util.addMethod(expect, 'hasAssertions', hasAssertions);
358
+ node_modules_chai.ZS.addMethod(expect, 'assertions', assertions);
359
+ node_modules_chai.ZS.addMethod(expect, 'hasAssertions', hasAssertions);
361
360
  expect.extend(dist.Pf);
362
361
  return expect;
363
362
  }
@@ -1812,7 +1811,7 @@ export const __webpack_modules__ = {
1812
1811
  api: {
1813
1812
  ...runnerAPI,
1814
1813
  expect,
1815
- assert: external_chai_.assert,
1814
+ assert: node_modules_chai.vA,
1816
1815
  rstest,
1817
1816
  rs: rstest
1818
1817
  }
@@ -1820,8 +1819,5 @@ export const __webpack_modules__ = {
1820
1819
  globalThis.RSTEST_API = runtime.api;
1821
1820
  return runtime;
1822
1821
  };
1823
- },
1824
- chai: function(module) {
1825
- module.exports = __WEBPACK_EXTERNAL_MODULE_chai__;
1826
1822
  }
1827
1823
  };
@@ -1,19 +1,19 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import { isCI } from "std-env";
4
3
  import { stripVTControlCharacters } from "node:util";
5
- export const __webpack_id__ = "669";
4
+ export const __webpack_id__ = "876";
6
5
  export const __webpack_ids__ = [
7
- "669"
6
+ "876"
8
7
  ];
9
8
  export const __webpack_modules__ = {
10
9
  "./src/core/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
11
10
  __webpack_require__.d(__webpack_exports__, {
12
11
  createRstest: ()=>createRstest
13
12
  });
14
- var external_node_fs_ = __webpack_require__("fs");
13
+ var external_node_fs_ = __webpack_require__("node:fs");
15
14
  var manager = __webpack_require__("../../node_modules/.pnpm/@vitest+snapshot@3.2.4/node_modules/@vitest/snapshot/dist/manager.js");
16
- var external_pathe_ = __webpack_require__("pathe");
15
+ var pathe_M_eThtNZ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
16
+ var dist = __webpack_require__("../../node_modules/.pnpm/std-env@3.9.0/node_modules/std-env/dist/index.mjs");
17
17
  var src_config = __webpack_require__("./src/config.ts");
18
18
  var stack_trace_parser_esm = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
19
19
  var utils = __webpack_require__("./src/utils/index.ts");
@@ -152,7 +152,7 @@ export const __webpack_modules__ = {
152
152
  getContent() {
153
153
  const summary = [];
154
154
  for (const module of this.runningModules){
155
- const relativePath = (0, external_pathe_.relative)(this.rootPath, module);
155
+ const relativePath = (0, pathe_M_eThtNZ.b)(this.rootPath, module);
156
156
  summary.push(`${utils.yW.bgYellow(utils.yW.bold(' RUNS '))} ${(0, utils.EQ)(relativePath)}`);
157
157
  }
158
158
  summary.push('');
@@ -171,6 +171,7 @@ export const __webpack_modules__ = {
171
171
  this.renderer?.finish();
172
172
  }
173
173
  }
174
+ var pathe_dist = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs");
174
175
  const getSummaryStatusString = (tasks, name = 'tests', showTotal = true)=>{
175
176
  if (0 === tasks.length) return utils.yW.dim(`no ${name}`);
176
177
  const passed = tasks.filter((result)=>'pass' === result.status);
@@ -229,7 +230,7 @@ export const __webpack_modules__ = {
229
230
  utils.vF.log(utils.yW.bold('Summary of all failing tests:'));
230
231
  utils.vF.log('');
231
232
  for (const test of failedTests){
232
- const relativePath = external_pathe_["default"].relative(rootPath, test.testPath);
233
+ const relativePath = pathe_dist.Ay.relative(rootPath, test.testPath);
233
234
  const nameStr = (0, utils.fN)(test);
234
235
  utils.vF.log(`${utils.yW.bgRed(' FAIL ')} ${(0, utils.EQ)(relativePath)} ${nameStr.length ? `${utils.yW.dim(utils.vO)} ${nameStr}` : ''}`);
235
236
  if (test.errors) {
@@ -276,14 +277,14 @@ export const __webpack_modules__ = {
276
277
  this.rootPath = rootPath;
277
278
  this.config = config;
278
279
  this.options = options;
279
- if (!isCI) this.statusRenderer = new StatusRenderer(rootPath);
280
+ if (!dist.JO) this.statusRenderer = new StatusRenderer(rootPath);
280
281
  }
281
282
  onTestFileStart(test) {
282
283
  this.statusRenderer?.addRunningModule(test.testPath);
283
284
  }
284
285
  onTestFileResult(test) {
285
286
  this.statusRenderer?.removeRunningModule(test.testPath);
286
- const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
287
+ const relativePath = (0, pathe_M_eThtNZ.b)(this.rootPath, test.testPath);
287
288
  const { slowTestThreshold } = this.config;
288
289
  logFileTitle(test, relativePath, slowTestThreshold);
289
290
  const isTooSlow = test.duration && test.duration > slowTestThreshold;
@@ -303,10 +304,10 @@ export const __webpack_modules__ = {
303
304
  const titles = [
304
305
  log.name
305
306
  ];
306
- const testPath = (0, external_pathe_.relative)(this.rootPath, log.testPath);
307
+ const testPath = (0, pathe_M_eThtNZ.b)(this.rootPath, log.testPath);
307
308
  if (log.trace) {
308
309
  const [frame] = (0, stack_trace_parser_esm.q)(log.trace);
309
- const filePath = (0, external_pathe_.relative)(this.rootPath, frame.file || '');
310
+ const filePath = (0, pathe_M_eThtNZ.b)(this.rootPath, frame.file || '');
310
311
  if (filePath !== testPath) titles.push((0, utils.EQ)(testPath));
311
312
  titles.push((0, utils.EQ)(filePath) + utils.yW.gray(`:${frame.lineNumber}:${frame.column}`));
312
313
  } else titles.push((0, utils.EQ)(testPath));
@@ -357,7 +358,7 @@ export const __webpack_modules__ = {
357
358
  for (const test of failedTests){
358
359
  const { testPath } = test;
359
360
  const nameStr = (0, utils.fN)(test);
360
- const shortPath = (0, external_pathe_.relative)(this.rootPath, testPath);
361
+ const shortPath = (0, pathe_M_eThtNZ.b)(this.rootPath, testPath);
361
362
  const title = `${shortPath} ${utils.vO} ${nameStr}`;
362
363
  for (const error of test.errors || []){
363
364
  let file = testPath;
@@ -414,7 +415,7 @@ export const __webpack_modules__ = {
414
415
  async createJUnitTestCase(test, getSourcemap) {
415
416
  const testCase = {
416
417
  name: (0, utils.fN)(test),
417
- classname: (0, external_pathe_.relative)(this.rootPath, test.testPath),
418
+ classname: (0, pathe_M_eThtNZ.b)(this.rootPath, test.testPath),
418
419
  time: (test.duration || 0) / 1000,
419
420
  status: test.status
420
421
  };
@@ -441,7 +442,7 @@ export const __webpack_modules__ = {
441
442
  const skipped = testCases.filter((test)=>'skip' === test.status || 'todo' === test.status).length;
442
443
  const totalTime = testCases.reduce((sum, test)=>sum + test.time, 0);
443
444
  return {
444
- name: (0, external_pathe_.relative)(this.rootPath, fileResult.testPath),
445
+ name: (0, pathe_M_eThtNZ.b)(this.rootPath, fileResult.testPath),
445
446
  tests: testCases.length,
446
447
  failures,
447
448
  errors,
@@ -513,7 +514,7 @@ export const __webpack_modules__ = {
513
514
  class VerboseReporter extends DefaultReporter {
514
515
  onTestFileResult(test) {
515
516
  this.statusRenderer?.removeRunningModule(test.testPath);
516
- const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
517
+ const relativePath = (0, pathe_M_eThtNZ.b)(this.rootPath, test.testPath);
517
518
  const { slowTestThreshold } = this.config;
518
519
  logFileTitle(test, relativePath, slowTestThreshold, true);
519
520
  for (const result of test.results)logCase(result, slowTestThreshold);
@@ -545,17 +546,20 @@ export const __webpack_modules__ = {
545
546
  this.fileFilters = fileFilters;
546
547
  this.configFilePath = configFilePath;
547
548
  const rootPath = userConfig.root ? (0, utils.FI)(cwd, userConfig.root) : cwd;
548
- const rstestConfig = (0, src_config.wX)(userConfig);
549
+ const rstestConfig = (0, src_config.wX)({
550
+ ...userConfig,
551
+ root: rootPath
552
+ });
549
553
  const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
550
554
  rootPath,
551
555
  config: rstestConfig
552
556
  }) : [];
553
557
  const snapshotManager = new manager.CW({
554
- updateSnapshot: rstestConfig.update ? 'all' : isCI ? 'none' : 'new'
558
+ updateSnapshot: rstestConfig.update ? 'all' : dist.JO ? 'none' : 'new'
555
559
  });
556
560
  this.reporters = reporters;
557
561
  this.snapshotManager = snapshotManager;
558
- this.version = "0.4.1";
562
+ this.version = "0.5.1";
559
563
  this.rootPath = rootPath;
560
564
  this.originalConfig = userConfig;
561
565
  this.normalizedConfig = rstestConfig;
@@ -565,7 +569,7 @@ export const __webpack_modules__ = {
565
569
  config.source ??= {};
566
570
  config.coverage = rstestConfig.coverage;
567
571
  if (!config.source.tsconfigPath) {
568
- const tsconfigPath = (0, external_pathe_.join)(config.root, utils.WB);
572
+ const tsconfigPath = (0, pathe_M_eThtNZ.j)(config.root, utils.WB);
569
573
  if ((0, external_node_fs_.existsSync)(tsconfigPath)) config.source.tsconfigPath = tsconfigPath;
570
574
  }
571
575
  return {
@@ -637,14 +641,14 @@ export const __webpack_modules__ = {
637
641
  }, config);
638
642
  const runTests = async ()=>{
639
643
  const { runTests } = await Promise.all([
640
- __webpack_require__.e("938"),
644
+ __webpack_require__.e("816"),
641
645
  __webpack_require__.e("33")
642
646
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
643
647
  await runTests(context);
644
648
  };
645
649
  const listTests = async (options)=>{
646
650
  const { listTests } = await Promise.all([
647
- __webpack_require__.e("938"),
651
+ __webpack_require__.e("816"),
648
652
  __webpack_require__.e("971")
649
653
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
650
654
  await listTests(context, options);
@@ -662,7 +666,7 @@ export const __webpack_modules__ = {
662
666
  parseErrorStacktrace: ()=>parseErrorStacktrace,
663
667
  printError: ()=>printError
664
668
  });
665
- var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
669
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
666
670
  var _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs");
667
671
  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");
668
672
  var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
@@ -678,6 +682,16 @@ export const __webpack_modules__ = {
678
682
  _utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(`${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.red(tips.join('\n'))}\n`);
679
683
  return;
680
684
  }
685
+ if (error.message.includes('is not defined')) {
686
+ const [, varName] = error.message.match(/(.*) is not defined/) || [];
687
+ if (varName) {
688
+ if (_utils__WEBPACK_IMPORTED_MODULE_3__.TE.includes(varName)) error.message = error.message.replace(`${varName} is not defined`, `${varName} is not defined. Did you forget to enable "globals" configuration?`);
689
+ else if ([
690
+ 'jest',
691
+ 'vitest'
692
+ ].includes(varName)) error.message = error.message.replace(`${varName} is not defined`, `${varName} is not defined. Did you mean rstest?`);
693
+ }
694
+ }
681
695
  _utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(`${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.red(_utils__WEBPACK_IMPORTED_MODULE_3__.yW.bold(errorName))}${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.red(`: ${error.message}`)}\n`);
682
696
  if (error.diff) {
683
697
  _utils__WEBPACK_IMPORTED_MODULE_3__.vF.log(error.diff);