vitest 1.0.0-beta.1 → 1.0.0-beta.3

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 (48) hide show
  1. package/LICENSE.md +0 -29
  2. package/dist/browser.d.ts +2 -2
  3. package/dist/browser.js +2 -2
  4. package/dist/child.js +9 -4
  5. package/dist/{chunk-api-setup.0aeabd21.js → chunk-api-setup.37a43981.js} +3 -2
  6. package/dist/{chunk-install-pkg.a430b45e.js → chunk-install-pkg.6349b322.js} +22 -21
  7. package/dist/{chunk-integrations-globals.c3c5e678.js → chunk-integrations-globals.9df12d91.js} +2 -3
  8. package/dist/{chunk-node-git.36288174.js → chunk-node-git.6c12e560.js} +1 -1
  9. package/dist/{chunk-runtime-console.ea222ffb.js → chunk-runtime-console.f3263f87.js} +19 -4
  10. package/dist/cli-wrapper.js +1 -1
  11. package/dist/cli.js +14 -18
  12. package/dist/config.cjs +2 -1
  13. package/dist/config.d.ts +3 -3
  14. package/dist/config.js +2 -1
  15. package/dist/coverage.d.ts +1 -1
  16. package/dist/coverage.js +2 -2
  17. package/dist/entry-vm.js +9 -4
  18. package/dist/entry.js +10 -5
  19. package/dist/environments.d.ts +1 -1
  20. package/dist/environments.js +1 -13
  21. package/dist/execute.d.ts +1 -1
  22. package/dist/execute.js +1 -1
  23. package/dist/index.d.ts +6 -5
  24. package/dist/index.js +3 -4
  25. package/dist/node.d.ts +5 -3
  26. package/dist/node.js +14 -13
  27. package/dist/{reporters-7bd09217.d.ts → reporters-1678fe04.d.ts} +84 -47
  28. package/dist/reporters.d.ts +1 -1
  29. package/dist/reporters.js +6 -1
  30. package/dist/runners.d.ts +3 -2
  31. package/dist/runners.js +33 -37
  32. package/dist/{suite-543d56bd.d.ts → suite-0579b50d.d.ts} +1 -1
  33. package/dist/suite.d.ts +2 -2
  34. package/dist/{vendor-environments.e73c5410.js → vendor-environments.dcc4a34e.js} +6 -37
  35. package/dist/{vendor-execute.07d1a420.js → vendor-execute.e6e4e89b.js} +1 -0
  36. package/dist/{vendor-index.d36f5516.js → vendor-index.3d079eea.js} +6 -1
  37. package/dist/{vendor-index.f7fcd5e8.js → vendor-index.68ecee35.js} +1 -1
  38. package/dist/{vendor-index.85fc950a.js → vendor-index.8efe7746.js} +375 -375
  39. package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
  40. package/dist/{vendor-node.bde9fb47.js → vendor-node.327f8f1f.js} +1996 -1984
  41. package/dist/{vendor-reporters.f6975b8d.js → vendor-reporters.b9600369.js} +42 -24
  42. package/dist/vendor-vi.d30b47ae.js +3510 -0
  43. package/dist/vm.js +10 -5
  44. package/dist/worker.js +9 -4
  45. package/package.json +12 -28
  46. package/dist/loader.js +0 -100
  47. package/dist/vendor-index.98139333.js +0 -129
  48. package/dist/vendor-vi.7f2b988f.js +0 -3491
@@ -1,6 +1,7 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import c from 'picocolors';
3
3
  import { b as isNode, c as relativePath } from './vendor-index.29282562.js';
4
+ import { UNKNOWN_TEST_ID } from './chunk-runtime-console.f3263f87.js';
4
5
  import { isAbsolute, relative, dirname, basename, resolve } from 'pathe';
5
6
  import { s as slash } from './vendor-base.9c08bbd0.js';
6
7
  import { g as getFullName, h as hasFailedSnapshot } from './vendor-tasks.f9d75aed.js';
@@ -228,6 +229,7 @@ class BaseReporter {
228
229
  _lastRunTimer;
229
230
  _lastRunCount = 0;
230
231
  _timeStart = /* @__PURE__ */ new Date();
232
+ _offUnhandledRejection;
231
233
  constructor() {
232
234
  this.registerUnhandledRejection();
233
235
  }
@@ -236,6 +238,10 @@ class BaseReporter {
236
238
  }
237
239
  onInit(ctx) {
238
240
  this.ctx = ctx;
241
+ ctx.onClose(() => {
242
+ var _a2;
243
+ (_a2 = this._offUnhandledRejection) == null ? void 0 : _a2.call(this);
244
+ });
239
245
  ctx.logger.printBanner();
240
246
  this.start = performance.now();
241
247
  }
@@ -302,8 +308,7 @@ class BaseReporter {
302
308
  else
303
309
  this.ctx.logger.log(WAIT_FOR_CHANGE_PASS);
304
310
  const hints = [];
305
- if (this.mode !== "typecheck")
306
- hints.push(HELP_HINT);
311
+ hints.push(HELP_HINT);
307
312
  if (failedSnap)
308
313
  hints.unshift(HELP_UPDATE_SNAP);
309
314
  else
@@ -369,7 +374,7 @@ ${FILENAME_PATTERN}${TESTNAME_PATTERN}`);
369
374
  if (!this.shouldLog(log))
370
375
  return;
371
376
  const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
372
- const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(" > ")) : "unknown test"}`));
377
+ const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== UNKNOWN_TEST_ID ? log.taskId : "unknown test"}`));
373
378
  process[log.type].write(`${header}
374
379
  ${log.content}
375
380
  `);
@@ -425,7 +430,7 @@ ${log.content}
425
430
  }
426
431
  logger.log(padTitle("Test Files"), getStateString(files));
427
432
  logger.log(padTitle("Tests"), getStateString(tests));
428
- if (this.mode === "typecheck") {
433
+ if (this.ctx.projects.some((c2) => c2.config.typecheck.enabled)) {
429
434
  const failed = tests.filter((t) => {
430
435
  var _a2, _b, _c;
431
436
  return ((_a2 = t.meta) == null ? void 0 : _a2.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
@@ -435,12 +440,18 @@ ${log.content}
435
440
  if (errors.length)
436
441
  logger.log(padTitle("Errors"), c.bold(c.red(`${errors.length} error${errors.length > 1 ? "s" : ""}`)));
437
442
  logger.log(padTitle("Start at"), formatTimeString(this._timeStart));
438
- if (this.watchFilters)
443
+ if (this.watchFilters) {
439
444
  logger.log(padTitle("Duration"), time(threadTime));
440
- else if (this.mode === "typecheck")
441
- logger.log(padTitle("Duration"), time(executionTime));
442
- else
443
- logger.log(padTitle("Duration"), time(executionTime) + c.dim(` (transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)})`));
445
+ } else {
446
+ let timers = `transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)}, environment ${time(environmentTime)}, prepare ${time(prepareTime)}`;
447
+ const typecheck = this.ctx.projects.reduce((acc, c2) => {
448
+ var _a2;
449
+ return acc + (((_a2 = c2.typechecker) == null ? void 0 : _a2.getResult().time) || 0);
450
+ }, 0);
451
+ if (typecheck)
452
+ timers += `, typecheck ${time(typecheck)}`;
453
+ logger.log(padTitle("Duration"), time(executionTime) + c.dim(` (${timers})`));
454
+ }
444
455
  logger.log();
445
456
  }
446
457
  async printErrorsSummary(files, errors) {
@@ -538,12 +549,16 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
538
549
  }
539
550
  }
540
551
  registerUnhandledRejection() {
541
- process.on("unhandledRejection", async (err) => {
552
+ const onUnhandledRejection = async (err) => {
542
553
  process.exitCode = 1;
543
554
  await this.ctx.logger.printError(err, { fullStack: true, type: "Unhandled Rejection" });
544
555
  this.ctx.logger.error("\n\n");
545
556
  process.exit(1);
546
- });
557
+ };
558
+ process.on("unhandledRejection", onUnhandledRejection);
559
+ this._offUnhandledRejection = () => {
560
+ process.off("unhandledRejection", onUnhandledRejection);
561
+ };
547
562
  }
548
563
  }
549
564
 
@@ -1454,7 +1469,7 @@ function renderBenchmark$1(task, tasks) {
1454
1469
  ].join("");
1455
1470
  }
1456
1471
  function renderTree$1(tasks, options, level = 0, maxRows) {
1457
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1472
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1458
1473
  const output = [];
1459
1474
  let currentRowCount = 0;
1460
1475
  for (const task of [...tasks].reverse()) {
@@ -1465,27 +1480,27 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
1465
1480
  prefix += formatProjectName(task.projectName);
1466
1481
  if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.retryCount) && task.result.retryCount > 0)
1467
1482
  suffix += c.yellow(` (retry x${task.result.retryCount})`);
1468
- if (task.type === "suite" && !((_b = task.meta) == null ? void 0 : _b.typecheck)) {
1483
+ if (task.type === "suite") {
1469
1484
  const tests = getTests(task);
1470
1485
  suffix += c.dim(` (${tests.length})`);
1471
1486
  }
1472
1487
  if (task.mode === "skip" || task.mode === "todo")
1473
1488
  suffix += ` ${c.dim(c.gray("[skipped]"))}`;
1474
- if (task.type === "test" && ((_c = task.result) == null ? void 0 : _c.repeatCount) && task.result.repeatCount > 0)
1489
+ if (task.type === "test" && ((_b = task.result) == null ? void 0 : _b.repeatCount) && task.result.repeatCount > 0)
1475
1490
  suffix += c.yellow(` (repeat x${task.result.repeatCount})`);
1476
- if (((_d = task.result) == null ? void 0 : _d.duration) != null) {
1491
+ if (((_c = task.result) == null ? void 0 : _c.duration) != null) {
1477
1492
  if (task.result.duration > DURATION_LONG$1)
1478
1493
  suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
1479
1494
  }
1480
- if (options.showHeap && ((_e = task.result) == null ? void 0 : _e.heap) != null)
1495
+ if (options.showHeap && ((_d = task.result) == null ? void 0 : _d.heap) != null)
1481
1496
  suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
1482
1497
  let name = task.name;
1483
1498
  if (level === 0)
1484
1499
  name = formatFilepath$1(name);
1485
1500
  const padding = " ".repeat(level);
1486
- const body = ((_f = task.meta) == null ? void 0 : _f.benchmark) ? renderBenchmark$1(task, tasks) : name;
1501
+ const body = ((_e = task.meta) == null ? void 0 : _e.benchmark) ? renderBenchmark$1(task, tasks) : name;
1487
1502
  taskOutput.push(padding + prefix + body + suffix);
1488
- if (((_g = task.result) == null ? void 0 : _g.state) !== "pass" && outputMap$1.get(task) != null) {
1503
+ if (((_f = task.result) == null ? void 0 : _f.state) !== "pass" && outputMap$1.get(task) != null) {
1489
1504
  let data = outputMap$1.get(task);
1490
1505
  if (typeof data === "string") {
1491
1506
  data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
@@ -1500,7 +1515,7 @@ function renderTree$1(tasks, options, level = 0, maxRows) {
1500
1515
  taskOutput.push(renderHookState(task, "beforeAll", level + 1));
1501
1516
  taskOutput.push(renderHookState(task, "beforeEach", level + 1));
1502
1517
  if (task.type === "suite" && task.tasks.length > 0) {
1503
- if (((_h = task.result) == null ? void 0 : _h.state) === "fail" || ((_i = task.result) == null ? void 0 : _i.state) === "run" || options.renderSucceed) {
1518
+ if (((_g = task.result) == null ? void 0 : _g.state) === "fail" || ((_h = task.result) == null ? void 0 : _h.state) === "run" || options.renderSucceed) {
1504
1519
  if (options.logger.ctx.config.hideSkippedTests) {
1505
1520
  const filteredTasks = task.tasks.filter((t) => t.mode !== "skip" && t.mode !== "todo");
1506
1521
  taskOutput.push(renderTree$1(filteredTasks, options, level + 1, maxRows));
@@ -1909,7 +1924,8 @@ let JsonReporter$1 = class JsonReporter {
1909
1924
  return;
1910
1925
  const project = this.ctx.getProjectByTaskId(test.id);
1911
1926
  const stack = parseErrorStacktrace(error, {
1912
- getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
1927
+ getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
1928
+ frameFilter: this.ctx.config.onStackTrace
1913
1929
  });
1914
1930
  const frame = stack[0];
1915
1931
  if (!frame)
@@ -2014,7 +2030,8 @@ class TapReporter {
2014
2030
  this.logger.indent();
2015
2031
  task.result.errors.forEach((error) => {
2016
2032
  const stacks = parseErrorStacktrace(error, {
2017
- getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
2033
+ getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
2034
+ frameFilter: this.ctx.config.onStackTrace
2018
2035
  });
2019
2036
  const stack = stacks[0];
2020
2037
  this.logger.log("---");
@@ -2127,7 +2144,8 @@ class JUnitReporter {
2127
2144
  await this.baseLog(escapeXML(errorDetails));
2128
2145
  const project = this.ctx.getProjectByTaskId(task.id);
2129
2146
  const stack = parseErrorStacktrace(error, {
2130
- getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
2147
+ getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
2148
+ frameFilter: this.ctx.config.onStackTrace
2131
2149
  });
2132
2150
  for (const frame of stack) {
2133
2151
  const path = relative(this.ctx.config.root, frame.file);
@@ -2155,13 +2173,13 @@ class JUnitReporter {
2155
2173
  name: task.name,
2156
2174
  time: getDuration(task)
2157
2175
  }, async () => {
2158
- var _a, _b;
2176
+ var _a;
2159
2177
  await this.writeLogs(task, "out");
2160
2178
  await this.writeLogs(task, "err");
2161
2179
  if (task.mode === "skip" || task.mode === "todo")
2162
2180
  await this.logger.log("<skipped/>");
2163
2181
  if (((_a = task.result) == null ? void 0 : _a.state) === "fail") {
2164
- const errors = ((_b = task.result.errors) == null ? void 0 : _b.length) ? task.result.errors : [task.result.error];
2182
+ const errors = task.result.errors || [];
2165
2183
  for (const error of errors) {
2166
2184
  await this.writeElement("failure", {
2167
2185
  message: error == null ? void 0 : error.message,