@vitest/runner 3.0.0 → 3.0.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.
@@ -49,8 +49,8 @@ function interpretTaskModes(file, namePattern, testLocations, onlyMode, parentIs
49
49
  }
50
50
  }
51
51
  let hasLocationMatch = parentMatchedWithLocation;
52
- if (testLocations !== void 0 && testLocations.length !== 0) {
53
- if (t.location && (testLocations == null ? void 0 : testLocations.includes(t.location.line))) {
52
+ if (testLocations !== undefined && testLocations.length !== 0) {
53
+ if (t.location && (testLocations == null ? undefined : testLocations.includes(t.location.line))) {
54
54
  t.mode = "run";
55
55
  matchedLocations.push(t.location.line);
56
56
  hasLocationMatch = true;
@@ -81,16 +81,16 @@ function interpretTaskModes(file, namePattern, testLocations, onlyMode, parentIs
81
81
  }
82
82
  };
83
83
  traverseSuite(file, parentIsOnly, false);
84
- const nonMatching = testLocations == null ? void 0 : testLocations.filter((loc) => !matchedLocations.includes(loc));
84
+ const nonMatching = testLocations == null ? undefined : testLocations.filter((loc) => !matchedLocations.includes(loc));
85
85
  if (nonMatching && nonMatching.length !== 0) {
86
86
  const message = nonMatching.length === 1 ? `line ${nonMatching[0]}` : `lines ${nonMatching.join(", ")}`;
87
- if (file.result === void 0) {
87
+ if (file.result === undefined) {
88
88
  file.result = {
89
89
  state: "fail",
90
90
  errors: []
91
91
  };
92
92
  }
93
- if (file.result.errors === void 0) {
93
+ if (file.result.errors === undefined) {
94
94
  file.result.errors = [];
95
95
  }
96
96
  file.result.errors.push(
@@ -171,7 +171,7 @@ function createFileTask(filepath, root, projectName, pool) {
171
171
  tasks: [],
172
172
  meta: /* @__PURE__ */ Object.create(null),
173
173
  projectName,
174
- file: void 0,
174
+ file: undefined,
175
175
  pool
176
176
  };
177
177
  file.file = file;
@@ -271,16 +271,16 @@ function hasFailed(suite) {
271
271
  return toArray(suite).some(
272
272
  (s) => {
273
273
  var _a;
274
- return ((_a = s.result) == null ? void 0 : _a.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
274
+ return ((_a = s.result) == null ? undefined : _a.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
275
275
  }
276
276
  );
277
277
  }
278
278
  function getNames(task) {
279
279
  const names = [task.name];
280
280
  let current = task;
281
- while (current == null ? void 0 : current.suite) {
281
+ while (current == null ? undefined : current.suite) {
282
282
  current = current.suite;
283
- if (current == null ? void 0 : current.name) {
283
+ if (current == null ? undefined : current.name) {
284
284
  names.unshift(current.name);
285
285
  }
286
286
  }
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ const collectorContext = {
22
22
  };
23
23
  function collectTask(task) {
24
24
  var _a;
25
- (_a = collectorContext.currentSuite) == null ? void 0 : _a.tasks.push(task);
25
+ (_a = collectorContext.currentSuite) == null ? undefined : _a.tasks.push(task);
26
26
  }
27
27
  async function runWithSuite(suite, fn) {
28
28
  const prev = collectorContext.currentSuite;
@@ -43,7 +43,7 @@ function withTimeout(fn, timeout, isHook = false) {
43
43
  clearTimeout(timer);
44
44
  reject(new Error(makeTimeoutMsg(isHook, timeout)));
45
45
  }, timeout);
46
- (_a = timer.unref) == null ? void 0 : _a.call(timer);
46
+ (_a = timer.unref) == null ? undefined : _a.call(timer);
47
47
  }),
48
48
  Promise.resolve(fn(...args)).then((result) => {
49
49
  return new Promise((resolve) => setTimeout(resolve, 0, result));
@@ -74,7 +74,7 @@ function createTestContext(test, runner) {
74
74
  withTimeout(handler, timeout ?? runner.config.hookTimeout, true)
75
75
  );
76
76
  };
77
- return ((_a = runner.extendTaskContext) == null ? void 0 : _a.call(runner, context)) || context;
77
+ return ((_a = runner.extendTaskContext) == null ? undefined : _a.call(runner, context)) || context;
78
78
  }
79
79
  function makeTimeoutMsg(isHook, timeout) {
80
80
  return `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
@@ -151,7 +151,7 @@ function withFixtures(fn, testContext) {
151
151
  return fn({});
152
152
  }
153
153
  const fixtures = getFixture(context);
154
- if (!(fixtures == null ? void 0 : fixtures.length)) {
154
+ if (!(fixtures == null ? undefined : fixtures.length)) {
155
155
  return fn(context);
156
156
  }
157
157
  const usedProps = getUsedProps(fn);
@@ -408,12 +408,12 @@ function createSuiteCollector(name, factory = () => {
408
408
  const task2 = {
409
409
  id: "",
410
410
  name: name2,
411
- suite: void 0,
411
+ suite: undefined,
412
412
  each: options.each,
413
413
  fails: options.fails,
414
- context: void 0,
414
+ context: undefined,
415
415
  type: "test",
416
- file: void 0,
416
+ file: undefined,
417
417
  retry: options.retry ?? runner.config.retry,
418
418
  repeats: options.repeats,
419
419
  mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
@@ -423,7 +423,7 @@ function createSuiteCollector(name, factory = () => {
423
423
  if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
424
424
  task2.concurrent = true;
425
425
  }
426
- task2.shuffle = suiteOptions == null ? void 0 : suiteOptions.shuffle;
426
+ task2.shuffle = suiteOptions == null ? undefined : suiteOptions.shuffle;
427
427
  const context = createTestContext(task2, runner);
428
428
  Object.defineProperty(task2, "context", {
429
429
  value: context,
@@ -435,7 +435,7 @@ function createSuiteCollector(name, factory = () => {
435
435
  task2,
436
436
  withTimeout(
437
437
  withAwaitAsyncAssertions(withFixtures(handler, context), task2),
438
- (options == null ? void 0 : options.timeout) ?? runner.config.testTimeout
438
+ (options == null ? undefined : options.timeout) ?? runner.config.testTimeout
439
439
  )
440
440
  );
441
441
  }
@@ -457,8 +457,8 @@ function createSuiteCollector(name, factory = () => {
457
457
  if (typeof suiteOptions === "object") {
458
458
  options = Object.assign({}, suiteOptions, options);
459
459
  }
460
- options.concurrent = this.concurrent || !this.sequential && (options == null ? void 0 : options.concurrent);
461
- options.sequential = this.sequential || !this.concurrent && (options == null ? void 0 : options.sequential);
460
+ options.concurrent = this.concurrent || !this.sequential && (options == null ? undefined : options.concurrent);
461
+ options.sequential = this.sequential || !this.concurrent && (options == null ? undefined : options.sequential);
462
462
  const test3 = task(formatName(name2), {
463
463
  ...this,
464
464
  ...options,
@@ -491,11 +491,11 @@ function createSuiteCollector(name, factory = () => {
491
491
  name,
492
492
  mode,
493
493
  each,
494
- file: void 0,
495
- shuffle: suiteOptions == null ? void 0 : suiteOptions.shuffle,
494
+ file: undefined,
495
+ shuffle: suiteOptions == null ? undefined : suiteOptions.shuffle,
496
496
  tasks: [],
497
497
  meta: /* @__PURE__ */ Object.create(null),
498
- concurrent: suiteOptions == null ? void 0 : suiteOptions.concurrent
498
+ concurrent: suiteOptions == null ? undefined : suiteOptions.concurrent
499
499
  };
500
500
  if (runner && includeLocation && runner.config.includeTaskLocation) {
501
501
  const limit = Error.stackTraceLimit;
@@ -542,7 +542,7 @@ function withAwaitAsyncAssertions(fn, task) {
542
542
  const fnResult = await fn(...args);
543
543
  if (task.promises) {
544
544
  const result = await Promise.allSettled(task.promises);
545
- const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
545
+ const errors = result.map((r) => r.status === "rejected" ? r.reason : undefined).filter(Boolean);
546
546
  if (errors.length) {
547
547
  throw errors;
548
548
  }
@@ -562,9 +562,9 @@ function createSuite() {
562
562
  const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
563
563
  const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
564
564
  options = {
565
- ...currentSuite == null ? void 0 : currentSuite.options,
565
+ ...currentSuite == null ? undefined : currentSuite.options,
566
566
  ...options,
567
- shuffle: this.shuffle ?? options.shuffle ?? ((_a = currentSuite == null ? void 0 : currentSuite.options) == null ? void 0 : _a.shuffle) ?? (runner == null ? void 0 : runner.config.sequence.shuffle)
567
+ shuffle: this.shuffle ?? options.shuffle ?? ((_a = currentSuite == null ? undefined : currentSuite.options) == null ? undefined : _a.shuffle) ?? (runner == null ? undefined : runner.config.sequence.shuffle)
568
568
  };
569
569
  const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
570
570
  const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
@@ -609,7 +609,7 @@ function createSuite() {
609
609
  }
610
610
  }
611
611
  });
612
- this.setContext("each", void 0);
612
+ this.setContext("each", undefined);
613
613
  };
614
614
  };
615
615
  suiteFn.for = function(cases, ...args) {
@@ -664,7 +664,7 @@ function createTaskCollector(fn, context) {
664
664
  }
665
665
  }
666
666
  });
667
- this.setContext("each", void 0);
667
+ this.setContext("each", undefined);
668
668
  };
669
669
  };
670
670
  taskFn.for = function(cases, ...args) {
@@ -695,7 +695,7 @@ function createTaskCollector(fn, context) {
695
695
  context || {},
696
696
  (key) => {
697
697
  var _a, _b;
698
- return (_b = (_a = getRunner()).injectValue) == null ? void 0 : _b.call(_a, key);
698
+ return (_b = (_a = getRunner()).injectValue) == null ? undefined : _b.call(_a, key);
699
699
  }
700
700
  );
701
701
  return createTest(function fn2(name, optionsOrFn, optionsOrTest) {
@@ -747,7 +747,7 @@ function formatTitle(template, items, idx) {
747
747
  (_, key) => {
748
748
  var _a, _b;
749
749
  return objDisplay(objectAttr(items[0], key), {
750
- truncate: (_b = (_a = runner == null ? void 0 : runner.config) == null ? void 0 : _a.chaiConfig) == null ? void 0 : _b.truncateThreshold
750
+ truncate: (_b = (_a = runner == null ? undefined : runner.config) == null ? undefined : _a.chaiConfig) == null ? undefined : _b.truncateThreshold
751
751
  });
752
752
  }
753
753
  );
@@ -866,10 +866,10 @@ async function collectTests(specs, runner) {
866
866
  const config = runner.config;
867
867
  for (const spec of specs) {
868
868
  const filepath = typeof spec === "string" ? spec : spec.filepath;
869
- const testLocations = typeof spec === "string" ? void 0 : spec.testLocations;
869
+ const testLocations = typeof spec === "string" ? undefined : spec.testLocations;
870
870
  const file = createFileTask(filepath, config.root, config.name, runner.pool);
871
871
  file.shuffle = config.sequence.shuffle;
872
- (_a = runner.onCollectStart) == null ? void 0 : _a.call(runner, file);
872
+ (_a = runner.onCollectStart) == null ? undefined : _a.call(runner, file);
873
873
  clearCollectorContext(filepath, runner);
874
874
  try {
875
875
  const setupFiles = toArray(config.setupFiles);
@@ -911,7 +911,7 @@ async function collectTests(specs, runner) {
911
911
  calculateSuiteHash(file);
912
912
  file.tasks.forEach((task) => {
913
913
  var _a2;
914
- if (((_a2 = task.suite) == null ? void 0 : _a2.id) === "") {
914
+ if (((_a2 = task.suite) == null ? undefined : _a2.id) === "") {
915
915
  delete task.suite;
916
916
  }
917
917
  });
@@ -1056,7 +1056,7 @@ async function sendTasksUpdate(runner) {
1056
1056
  const taskPacks = Array.from(packs).map(([id, task]) => {
1057
1057
  return [id, task[0], task[1]];
1058
1058
  });
1059
- const p = (_a = runner.onTaskUpdate) == null ? void 0 : _a.call(runner, taskPacks, eventsPacks);
1059
+ const p = (_a = runner.onTaskUpdate) == null ? undefined : _a.call(runner, taskPacks, eventsPacks);
1060
1060
  eventsPacks.length = 0;
1061
1061
  packs.clear();
1062
1062
  return p;
@@ -1074,11 +1074,11 @@ async function callCleanupHooks(cleanups) {
1074
1074
  }
1075
1075
  async function runTest(test, runner) {
1076
1076
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1077
- await ((_a = runner.onBeforeRunTask) == null ? void 0 : _a.call(runner, test));
1077
+ await ((_a = runner.onBeforeRunTask) == null ? undefined : _a.call(runner, test));
1078
1078
  if (test.mode !== "run" && test.mode !== "queued") {
1079
1079
  return;
1080
1080
  }
1081
- if (((_b = test.result) == null ? void 0 : _b.state) === "fail") {
1081
+ if (((_b = test.result) == null ? undefined : _b.state) === "fail") {
1082
1082
  updateTask("test-failed-early", test, runner);
1083
1083
  return;
1084
1084
  }
@@ -1134,11 +1134,11 @@ async function runTest(test, runner) {
1134
1134
  } catch (e) {
1135
1135
  failTask(test.result, e, runner.config.diffOptions);
1136
1136
  }
1137
- if (((_e = test.result) == null ? void 0 : _e.pending) || ((_f = test.result) == null ? void 0 : _f.state) === "skip") {
1137
+ if (((_e = test.result) == null ? undefined : _e.pending) || ((_f = test.result) == null ? undefined : _f.state) === "skip") {
1138
1138
  test.mode = "skip";
1139
- test.result = { state: "skip", note: (_g = test.result) == null ? void 0 : _g.note, pending: true };
1139
+ test.result = { state: "skip", note: (_g = test.result) == null ? undefined : _g.note, pending: true };
1140
1140
  updateTask("test-finished", test, runner);
1141
- setCurrentTest(void 0);
1141
+ setCurrentTest(undefined);
1142
1142
  return;
1143
1143
  }
1144
1144
  try {
@@ -1165,8 +1165,8 @@ async function runTest(test, runner) {
1165
1165
  runner.config.sequence.hooks
1166
1166
  );
1167
1167
  }
1168
- test.onFailed = void 0;
1169
- test.onFinished = void 0;
1168
+ test.onFailed = undefined;
1169
+ test.onFinished = undefined;
1170
1170
  if (test.result.state === "pass") {
1171
1171
  break;
1172
1172
  }
@@ -1184,12 +1184,12 @@ async function runTest(test, runner) {
1184
1184
  test.result.errors = [error];
1185
1185
  } else {
1186
1186
  test.result.state = "pass";
1187
- test.result.errors = void 0;
1187
+ test.result.errors = undefined;
1188
1188
  }
1189
1189
  }
1190
- setCurrentTest(void 0);
1190
+ setCurrentTest(undefined);
1191
1191
  test.result.duration = now() - start;
1192
- await ((_i = runner.onAfterRunTask) == null ? void 0 : _i.call(runner, test));
1192
+ await ((_i = runner.onAfterRunTask) == null ? undefined : _i.call(runner, test));
1193
1193
  updateTask("test-finished", test, runner);
1194
1194
  }
1195
1195
  function failTask(result, err, diffOptions) {
@@ -1219,8 +1219,8 @@ function markTasksAsSkipped(suite, runner) {
1219
1219
  }
1220
1220
  async function runSuite(suite, runner) {
1221
1221
  var _a, _b, _c, _d;
1222
- await ((_a = runner.onBeforeRunSuite) == null ? void 0 : _a.call(runner, suite));
1223
- if (((_b = suite.result) == null ? void 0 : _b.state) === "fail") {
1222
+ await ((_a = runner.onBeforeRunSuite) == null ? undefined : _a.call(runner, suite));
1223
+ if (((_b = suite.result) == null ? undefined : _b.state) === "fail") {
1224
1224
  markTasksAsSkipped(suite, runner);
1225
1225
  updateTask("suite-failed-early", suite, runner);
1226
1226
  return;
@@ -1289,7 +1289,7 @@ async function runSuite(suite, runner) {
1289
1289
  if (suite.mode === "run" || suite.mode === "queued") {
1290
1290
  if (!runner.config.passWithNoTests && !hasTests(suite)) {
1291
1291
  suite.result.state = "fail";
1292
- if (!((_c = suite.result.errors) == null ? void 0 : _c.length)) {
1292
+ if (!((_c = suite.result.errors) == null ? undefined : _c.length)) {
1293
1293
  const error = processError(
1294
1294
  new Error(`No test found in suite ${suite.name}`)
1295
1295
  );
@@ -1303,7 +1303,7 @@ async function runSuite(suite, runner) {
1303
1303
  }
1304
1304
  suite.result.duration = now() - start;
1305
1305
  updateTask("suite-finished", suite, runner);
1306
- await ((_d = runner.onAfterRunSuite) == null ? void 0 : _d.call(runner, suite));
1306
+ await ((_d = runner.onAfterRunSuite) == null ? undefined : _d.call(runner, suite));
1307
1307
  }
1308
1308
  }
1309
1309
  let limitMaxConcurrency;
@@ -1319,7 +1319,7 @@ async function runFiles(files, runner) {
1319
1319
  limitMaxConcurrency ?? (limitMaxConcurrency = limitConcurrency(runner.config.maxConcurrency));
1320
1320
  for (const file of files) {
1321
1321
  if (!file.tasks.length && !runner.config.passWithNoTests) {
1322
- if (!((_b = (_a = file.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length)) {
1322
+ if (!((_b = (_a = file.result) == null ? undefined : _a.errors) == null ? undefined : _b.length)) {
1323
1323
  const error = processError(
1324
1324
  new Error(`No test suite found in file ${file.filepath}`)
1325
1325
  );
@@ -1335,21 +1335,21 @@ async function runFiles(files, runner) {
1335
1335
  async function startTests(specs, runner) {
1336
1336
  var _a, _b, _c, _d;
1337
1337
  const paths = specs.map((f) => typeof f === "string" ? f : f.filepath);
1338
- await ((_a = runner.onBeforeCollect) == null ? void 0 : _a.call(runner, paths));
1338
+ await ((_a = runner.onBeforeCollect) == null ? undefined : _a.call(runner, paths));
1339
1339
  const files = await collectTests(specs, runner);
1340
- await ((_b = runner.onCollected) == null ? void 0 : _b.call(runner, files));
1341
- await ((_c = runner.onBeforeRunFiles) == null ? void 0 : _c.call(runner, files));
1340
+ await ((_b = runner.onCollected) == null ? undefined : _b.call(runner, files));
1341
+ await ((_c = runner.onBeforeRunFiles) == null ? undefined : _c.call(runner, files));
1342
1342
  await runFiles(files, runner);
1343
- await ((_d = runner.onAfterRunFiles) == null ? void 0 : _d.call(runner, files));
1343
+ await ((_d = runner.onAfterRunFiles) == null ? undefined : _d.call(runner, files));
1344
1344
  await sendTasksUpdate(runner);
1345
1345
  return files;
1346
1346
  }
1347
1347
  async function publicCollect(specs, runner) {
1348
1348
  var _a, _b;
1349
1349
  const paths = specs.map((f) => typeof f === "string" ? f : f.filepath);
1350
- await ((_a = runner.onBeforeCollect) == null ? void 0 : _a.call(runner, paths));
1350
+ await ((_a = runner.onBeforeCollect) == null ? undefined : _a.call(runner, paths));
1351
1351
  const files = await collectTests(specs, runner);
1352
- await ((_b = runner.onCollected) == null ? void 0 : _b.call(runner, files));
1352
+ await ((_b = runner.onCollected) == null ? undefined : _b.call(runner, files));
1353
1353
  return files;
1354
1354
  }
1355
1355
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -38,8 +38,8 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "pathe": "^2.0.0",
42
- "@vitest/utils": "3.0.0"
41
+ "pathe": "^2.0.1",
42
+ "@vitest/utils": "3.0.1"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "rimraf dist && rollup -c",