vitest 0.20.2 → 0.21.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.
Files changed (35) hide show
  1. package/LICENSE.md +29 -0
  2. package/dist/browser.d.ts +9 -1887
  3. package/dist/browser.mjs +7 -7
  4. package/dist/{chunk-api-setup.7c4c8879.mjs → chunk-api-setup.7a6ba7fb.mjs} +5 -5
  5. package/dist/{chunk-constants.16825f0c.mjs → chunk-constants.26dc9f85.mjs} +1 -1
  6. package/dist/{chunk-defaults.1c51d585.mjs → chunk-defaults.02abff90.mjs} +2 -2
  7. package/dist/{chunk-integrations-globals.56a11010.mjs → chunk-integrations-globals.44a8f047.mjs} +6 -6
  8. package/dist/{chunk-mock-date.9160e13b.mjs → chunk-mock-date.bc81a3ac.mjs} +11 -8
  9. package/dist/{chunk-node-git.43dbdd42.mjs → chunk-node-git.c2be9c49.mjs} +1 -1
  10. package/dist/{chunk-runtime-chain.b6c2cdbc.mjs → chunk-runtime-chain.98d42d89.mjs} +30 -21
  11. package/dist/{chunk-runtime-error.0aa0dc06.mjs → chunk-runtime-error.87a2b5a2.mjs} +12 -11
  12. package/dist/{chunk-runtime-hooks.3ee34848.mjs → chunk-runtime-hooks.453f8858.mjs} +4 -4
  13. package/dist/{chunk-runtime-mocker.0a8f7c5e.mjs → chunk-runtime-mocker.23b62bfa.mjs} +34 -12
  14. package/dist/{chunk-runtime-rpc.dbf0b31d.mjs → chunk-runtime-rpc.b50ab560.mjs} +1 -1
  15. package/dist/{chunk-utils-source-map.8198ebd9.mjs → chunk-utils-source-map.94107ee8.mjs} +1 -1
  16. package/dist/{chunk-vite-node-client.a247c2c2.mjs → chunk-vite-node-client.fdd9592c.mjs} +7 -3
  17. package/dist/{chunk-vite-node-debug.c5887932.mjs → chunk-vite-node-debug.09afb76f.mjs} +1 -1
  18. package/dist/{chunk-vite-node-externalize.45323563.mjs → chunk-vite-node-externalize.27aee038.mjs} +34 -18
  19. package/dist/chunk-vite-node-utils.f34df9d3.mjs +6887 -0
  20. package/dist/cli.mjs +8 -8
  21. package/dist/config.d.ts +2 -67
  22. package/dist/entry.mjs +7 -7
  23. package/dist/global-60f880c6.d.ts +1779 -0
  24. package/dist/index-4a906fa4.d.ts +164 -0
  25. package/dist/index.d.ts +29 -1903
  26. package/dist/index.mjs +5 -5
  27. package/dist/loader.mjs +73 -17
  28. package/dist/mocker-5e2a8e41.d.ts +3 -0
  29. package/dist/node.d.ts +7 -1667
  30. package/dist/node.mjs +9 -9
  31. package/dist/suite.mjs +4 -4
  32. package/dist/{vendor-index.de788b6a.mjs → vendor-index.ae96af6e.mjs} +14 -14
  33. package/dist/worker.mjs +6 -6
  34. package/package.json +11 -11
  35. package/dist/chunk-vite-node-utils.9dfd1e3f.mjs +0 -1114
@@ -1,32 +1,32 @@
1
- import { j as join, z as basename, d as dirname, y as resolve, A as AggregateErrorPonyfill, p as picocolors, B as isAbsolute, C as relative, s as slash$2, l as isNode, o as relativePath, D as getTests, e as getFullName, x as hasFailed, E as hasFailedSnapshot, F as getSuites, v as shuffle, t as toArray$1, G as normalize, n as noop$1, H as deepMerge, I as toNamespacedPath, g as getCallLastIndex, f as notNullish, J as ensurePackageInstalled, K as stdout } from './chunk-mock-date.9160e13b.mjs';
2
- import { p as pLimit, c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage, d as envPackageNames } from './chunk-defaults.1c51d585.mjs';
1
+ import { y as resolve, j as join, z as basename, d as dirname, A as AggregateErrorPonyfill, p as picocolors, B as isAbsolute, C as relative, s as slash$2, l as isNode, o as relativePath, D as getTests, e as getFullName, x as hasFailed, E as hasFailedSnapshot, F as getSuites, v as shuffle, t as toArray$1, G as normalize, n as noop$1, H as deepMerge, I as toNamespacedPath, g as getCallLastIndex, f as notNullish, J as ensurePackageInstalled, K as stdout } from './chunk-mock-date.bc81a3ac.mjs';
2
+ import { p as pLimit, c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage, d as envPackageNames } from './chunk-defaults.02abff90.mjs';
3
3
  import { loadConfigFromFile, createServer, mergeConfig } from 'vite';
4
4
  import path$a from 'path';
5
5
  import _url, { fileURLToPath } from 'url';
6
6
  import process$1 from 'process';
7
7
  import fs$8, { promises, existsSync, readFileSync } from 'fs';
8
- import { d as distDir, r as rootDir, c as configFiles, a as defaultPort } from './chunk-constants.16825f0c.mjs';
8
+ import { d as distDir, r as rootDir, c as configFiles, a as defaultPort } from './chunk-constants.26dc9f85.mjs';
9
9
  import require$$0, { cpus, hostname } from 'os';
10
10
  import util$2 from 'util';
11
11
  import require$$0$1 from 'stream';
12
12
  import require$$2 from 'events';
13
13
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
14
- import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.a247c2c2.mjs';
14
+ import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.fdd9592c.mjs';
15
15
  import createDebug from 'debug';
16
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.9dfd1e3f.mjs';
16
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.f34df9d3.mjs';
17
17
  import { MessageChannel } from 'worker_threads';
18
18
  import { Tinypool } from 'tinypool';
19
19
  import { performance } from 'perf_hooks';
20
- import { c as stripAnsi, d as cliTruncate, p as parseStacktrace, e as stringWidth, h as ansiStyles, i as sliceAnsi, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, b as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.8198ebd9.mjs';
20
+ import { c as stripAnsi, d as cliTruncate, p as parseStacktrace, e as stringWidth, h as ansiStyles, i as sliceAnsi, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, b as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.94107ee8.mjs';
21
21
  import { b as safeSetInterval, c as safeClearInterval, s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
22
22
  import { resolveModule } from 'local-pkg';
23
23
  import { createHash } from 'crypto';
24
24
  import { o as onetime, s as signalExit } from './vendor-index.61438b77.mjs';
25
25
  import MagicString from './chunk-magic-string.efe26975.mjs';
26
26
  import require$$0$2 from 'readline';
27
- import { p as prompts } from './vendor-index.de788b6a.mjs';
27
+ import { p as prompts } from './vendor-index.ae96af6e.mjs';
28
28
 
29
- var version$1 = "0.20.2";
29
+ var version$1 = "0.21.1";
30
30
 
31
31
  class EndError extends Error {
32
32
  constructor(value) {
@@ -6850,14 +6850,14 @@ class ViteNodeServer {
6850
6850
  }, options.debug ?? {});
6851
6851
  }
6852
6852
  if (options.debug)
6853
- import('./chunk-vite-node-debug.c5887932.mjs').then((r) => this.debugger = new r.Debugger(server.config.root, options.debug));
6853
+ import('./chunk-vite-node-debug.09afb76f.mjs').then((r) => this.debugger = new r.Debugger(server.config.root, options.debug));
6854
6854
  }
6855
6855
  shouldExternalize(id) {
6856
6856
  return shouldExternalize(id, this.options.deps, this.externalizeCache);
6857
6857
  }
6858
6858
  async resolveId(id, importer) {
6859
6859
  if (importer && !importer.startsWith(this.server.config.root))
6860
- importer = join(this.server.config.root, importer);
6860
+ importer = resolve(this.server.config.root, importer);
6861
6861
  const mode = importer && this.getTransformMode(importer) || "ssr";
6862
6862
  return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
6863
6863
  }
@@ -7292,6 +7292,9 @@ function elegantSpinner() {
7292
7292
  return spinnerFrames[index];
7293
7293
  };
7294
7294
  }
7295
+ function formatTimeString(date) {
7296
+ return date.toTimeString().split(" ")[0];
7297
+ }
7295
7298
 
7296
7299
  var _a;
7297
7300
  const BADGE_PADDING = " ";
@@ -7313,6 +7316,7 @@ class BaseReporter {
7313
7316
  this._filesInWatchMode = /* @__PURE__ */ new Map();
7314
7317
  this._lastRunTimeout = 0;
7315
7318
  this._lastRunCount = 0;
7319
+ this._timeStart = new Date();
7316
7320
  this.registerUnhandledRejection();
7317
7321
  }
7318
7322
  onInit(ctx) {
@@ -7426,6 +7430,7 @@ ${BADGE}${TRIGGER}
7426
7430
  ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7427
7431
  `);
7428
7432
  }
7433
+ this._timeStart = new Date();
7429
7434
  this.start = performance.now();
7430
7435
  }
7431
7436
  onUserConsoleLog(log) {
@@ -7496,10 +7501,11 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7496
7501
  }
7497
7502
  logger.log(padTitle("Test Files"), getStateString(files));
7498
7503
  logger.log(padTitle("Tests"), getStateString(tests));
7504
+ logger.log(padTitle("Start at"), formatTimeString(this._timeStart));
7499
7505
  if (this.watchFilters)
7500
- logger.log(padTitle("Time"), time(threadTime));
7506
+ logger.log(padTitle("Duration"), time(threadTime));
7501
7507
  else
7502
- logger.log(padTitle("Time"), time(executionTime) + picocolors.exports.gray(` (setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
7508
+ logger.log(padTitle("Duration"), time(executionTime) + picocolors.exports.gray(` (setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
7503
7509
  logger.log();
7504
7510
  }
7505
7511
  async printTaskErrors(tasks, errorDivider) {
@@ -7971,7 +7977,7 @@ function tapString(str) {
7971
7977
  class TapReporter {
7972
7978
  onInit(ctx) {
7973
7979
  this.ctx = ctx;
7974
- this.logger = new IndentedLogger(this.ctx.logger.log.bind(this.ctx));
7980
+ this.logger = new IndentedLogger(ctx.logger.log.bind(ctx.logger));
7975
7981
  }
7976
7982
  static getComment(task) {
7977
7983
  var _a;
@@ -8244,6 +8250,11 @@ function createReporters(reporterReferences, runner) {
8244
8250
  return Promise.all(promisedReporters);
8245
8251
  }
8246
8252
 
8253
+ const isAggregateError = (err) => {
8254
+ if (typeof AggregateError !== "undefined" && err instanceof AggregateError)
8255
+ return true;
8256
+ return err instanceof Error && "errors" in err;
8257
+ };
8247
8258
  class StateManager {
8248
8259
  constructor() {
8249
8260
  this.filesMap = /* @__PURE__ */ new Map();
@@ -8254,6 +8265,8 @@ class StateManager {
8254
8265
  this.errorsSet = /* @__PURE__ */ new Set();
8255
8266
  }
8256
8267
  catchError(err, type) {
8268
+ if (isAggregateError(err))
8269
+ return err.errors.forEach((error) => this.catchError(error, type));
8257
8270
  err.type = type;
8258
8271
  this.errorsSet.add(err);
8259
8272
  }
@@ -8567,7 +8580,7 @@ function resolveConfig(options, viteConfig) {
8567
8580
  resolved.deps.inline.push(...extraInlineDeps);
8568
8581
  }
8569
8582
  }
8570
- (_c = resolved.deps).registerNodeLoader ?? (_c.registerNodeLoader = true);
8583
+ (_c = resolved.deps).registerNodeLoader ?? (_c.registerNodeLoader = false);
8571
8584
  resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
8572
8585
  const CI = !!process.env.CI;
8573
8586
  const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
@@ -9093,7 +9106,7 @@ createLogUpdate(process$1.stdout);
9093
9106
 
9094
9107
  createLogUpdate(process$1.stderr);
9095
9108
 
9096
- var version = "0.20.2";
9109
+ var version = "0.21.1";
9097
9110
 
9098
9111
  function fileFromParsedStack(stack) {
9099
9112
  var _a, _b;
@@ -9341,7 +9354,7 @@ class Logger {
9341
9354
  async printUnhandledErrors(errors) {
9342
9355
  const errorMessage = picocolors.exports.red(picocolors.exports.bold(`
9343
9356
  Vitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run. This might cause false positive tests.
9344
- Please, resolve all the errors to make sure your tests are not affected.`));
9357
+ Please, resolve all errors to make sure your tests are not affected.`));
9345
9358
  this.log(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Unhandled Errors ")))));
9346
9359
  this.log(errorMessage);
9347
9360
  await Promise.all(errors.map(async (err) => {
@@ -9460,7 +9473,7 @@ class Vitest {
9460
9473
  }
9461
9474
  async filterTestsBySource(tests) {
9462
9475
  if (this.config.changed && !this.config.related) {
9463
- const { VitestGit } = await import('./chunk-node-git.43dbdd42.mjs');
9476
+ const { VitestGit } = await import('./chunk-node-git.c2be9c49.mjs');
9464
9477
  const vitestGit = new VitestGit(this.config.root);
9465
9478
  const related2 = await vitestGit.findChangedFiles({
9466
9479
  changedSince: this.config.changed
@@ -9962,6 +9975,9 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
9962
9975
  {
9963
9976
  name: "vitest",
9964
9977
  enforce: "pre",
9978
+ options() {
9979
+ this.meta.watchMode = false;
9980
+ },
9965
9981
  config(viteConfig) {
9966
9982
  const preOptions = deepMerge({}, configDefaults, options, viteConfig.test ?? {});
9967
9983
  preOptions.api = resolveApiConfig(preOptions);
@@ -10046,7 +10062,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10046
10062
  await ctx.setServer(options, server);
10047
10063
  haveStarted = true;
10048
10064
  if (options.api && options.watch)
10049
- (await import('./chunk-api-setup.7c4c8879.mjs')).setup(ctx);
10065
+ (await import('./chunk-api-setup.7a6ba7fb.mjs')).setup(ctx);
10050
10066
  } catch (err) {
10051
10067
  ctx.logger.printError(err, true);
10052
10068
  process.exit(1);