vitest 0.22.0 → 0.22.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 (33) hide show
  1. package/dist/browser.d.ts +3 -3
  2. package/dist/browser.mjs +8 -7
  3. package/dist/{chunk-api-setup.ecd02c18.mjs → chunk-api-setup.377c28aa.mjs} +7 -8
  4. package/dist/chunk-constants.71e8a211.mjs +284 -0
  5. package/dist/{chunk-integrations-globals.e81d2091.mjs → chunk-integrations-globals.60af7da3.mjs} +8 -9
  6. package/dist/{chunk-mock-date.debe9954.mjs → chunk-mock-date.304e29b1.mjs} +6 -189
  7. package/dist/{chunk-node-git.71b74da4.mjs → chunk-node-git.9a7e3153.mjs} +3 -5
  8. package/dist/{chunk-runtime-chain.6e363ba2.mjs → chunk-runtime-chain.be610650.mjs} +4 -4
  9. package/dist/{chunk-runtime-error.975bd80a.mjs → chunk-runtime-error.1104e45a.mjs} +10 -10
  10. package/dist/{chunk-runtime-hooks.4789e99d.mjs → chunk-runtime-hooks.5d7073db.mjs} +3 -3
  11. package/dist/{chunk-runtime-mocker.c91d29ce.mjs → chunk-runtime-mocker.49d21aa6.mjs} +4 -4
  12. package/dist/{chunk-runtime-rpc.29488183.mjs → chunk-runtime-rpc.57586b73.mjs} +1 -1
  13. package/dist/{chunk-utils-source-map.2a082ffd.mjs → chunk-utils-source-map.bbf3ad19.mjs} +2 -2
  14. package/dist/{chunk-vite-node-client.d1ead698.mjs → chunk-vite-node-client.cddda63d.mjs} +44 -20
  15. package/dist/{chunk-vite-node-debug.ff1d2a9f.mjs → chunk-vite-node-debug.536c4c5b.mjs} +3 -4
  16. package/dist/{chunk-vite-node-externalize.3a38c8af.mjs → chunk-vite-node-externalize.c843f497.mjs} +42 -24
  17. package/dist/{chunk-vite-node-utils.d8e5ff7b.mjs → chunk-vite-node-utils.b432150c.mjs} +1 -1
  18. package/dist/cli-wrapper.mjs +43 -26
  19. package/dist/cli.mjs +9 -10
  20. package/dist/config.d.ts +1 -1
  21. package/dist/entry.mjs +8 -7
  22. package/dist/{global-74489cc9.d.ts → global-fe52f84b.d.ts} +20 -6
  23. package/dist/{index-9eded9ec.d.ts → index-ea17aa0c.d.ts} +1 -1
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.mjs +7 -6
  26. package/dist/loader.mjs +3 -3
  27. package/dist/node.d.ts +2 -2
  28. package/dist/node.mjs +11 -12
  29. package/dist/suite.mjs +6 -5
  30. package/dist/worker.mjs +9 -10
  31. package/package.json +5 -5
  32. package/dist/chunk-constants.d3f8437b.mjs +0 -38
  33. package/dist/vendor-picocolors.807856aa.mjs +0 -64
@@ -1,11 +1,11 @@
1
1
  import { e as environments, t as takeCoverageInsideWorker, p as pLimit } from './chunk-integrations-coverage.d205bd87.mjs';
2
- import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.4789e99d.mjs';
3
- import { h as deepClone, k as getType, l as isNode, R as RealDate, t as toArray, o as relativePath, p as isBrowser, q as partitionSuiteChildren, u as shuffle, v as hasTests, w as hasFailed, e as getFullName } from './chunk-mock-date.debe9954.mjs';
4
- import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.6e363ba2.mjs';
5
- import { r as rpc } from './chunk-runtime-rpc.29488183.mjs';
2
+ import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.5d7073db.mjs';
3
+ import { f as deepClone, h as getType, j as isNode, R as RealDate, t as toArray, k as relativePath, l as isBrowser, p as partitionSuiteChildren, o as shuffle, q as hasTests, u as hasFailed, d as getFullName } from './chunk-mock-date.304e29b1.mjs';
4
+ import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.be610650.mjs';
5
+ import { r as rpc } from './chunk-runtime-rpc.57586b73.mjs';
6
6
  import util$1 from 'util';
7
7
  import { util } from 'chai';
8
- import { s as stringify } from './chunk-utils-source-map.2a082ffd.mjs';
8
+ import { s as stringify } from './chunk-utils-source-map.bbf3ad19.mjs';
9
9
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
10
10
  import { a as safeClearTimeout, s as safeSetTimeout } from './chunk-utils-timers.b48455ed.mjs';
11
11
 
@@ -131,7 +131,7 @@ async function setupGlobalEnv(config) {
131
131
  if (isNode)
132
132
  await setupConsoleLogSpy();
133
133
  if (config.globals)
134
- (await import('./chunk-integrations-globals.e81d2091.mjs')).registerApiGlobally();
134
+ (await import('./chunk-integrations-globals.60af7da3.mjs')).registerApiGlobally();
135
135
  }
136
136
  function setupDefines(defines) {
137
137
  for (const key in defines)
@@ -442,7 +442,7 @@ async function sendTasksUpdate() {
442
442
  async function runTest(test) {
443
443
  var _a, _b;
444
444
  if (test.mode !== "run") {
445
- const { getSnapshotClient } = await import('./chunk-runtime-chain.6e363ba2.mjs').then(function (n) { return n.p; });
445
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.be610650.mjs').then(function (n) { return n.p; });
446
446
  getSnapshotClient().skipTestSnapshots(test);
447
447
  return;
448
448
  }
@@ -458,7 +458,7 @@ async function runTest(test) {
458
458
  updateTask(test);
459
459
  clearModuleMocks();
460
460
  if (isNode) {
461
- const { getSnapshotClient } = await import('./chunk-runtime-chain.6e363ba2.mjs').then(function (n) { return n.p; });
461
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.be610650.mjs').then(function (n) { return n.p; });
462
462
  await getSnapshotClient().setTest(test);
463
463
  }
464
464
  const workerState = getWorkerState();
@@ -511,7 +511,7 @@ async function runTest(test) {
511
511
  if (isBrowser && test.result.error)
512
512
  console.error(test.result.error.message, test.result.error.stackStr);
513
513
  if (isNode) {
514
- const { getSnapshotClient } = await import('./chunk-runtime-chain.6e363ba2.mjs').then(function (n) { return n.p; });
514
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.be610650.mjs').then(function (n) { return n.p; });
515
515
  getSnapshotClient().clearTest();
516
516
  }
517
517
  test.result.duration = now() - start;
@@ -623,7 +623,7 @@ async function startTestsBrowser(paths, config) {
623
623
  async function startTestsNode(paths, config) {
624
624
  const files = await collectTests(paths, config);
625
625
  rpc().onCollected(files);
626
- const { getSnapshotClient } = await import('./chunk-runtime-chain.6e363ba2.mjs').then(function (n) { return n.p; });
626
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.be610650.mjs').then(function (n) { return n.p; });
627
627
  getSnapshotClient().clear();
628
628
  await runFiles(files, config);
629
629
  const coverage = await takeCoverageInsideWorker(config.coverage);
@@ -1,7 +1,7 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, c as createExpect, b as globalExpect } from './chunk-runtime-chain.6e363ba2.mjs';
2
- import { R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.debe9954.mjs';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, c as createExpect, b as globalExpect } from './chunk-runtime-chain.be610650.mjs';
2
+ import { R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.304e29b1.mjs';
3
3
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
4
- import { p as parseStacktrace } from './chunk-utils-source-map.2a082ffd.mjs';
4
+ import { p as parseStacktrace } from './chunk-utils-source-map.bbf3ad19.mjs';
5
5
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
6
6
  import util from 'util';
7
7
  import { spyOn, fn, isMockFunction, spies } from './spy.mjs';
@@ -1,9 +1,9 @@
1
- import { V as ViteNodeRunner } from './chunk-vite-node-client.d1ead698.mjs';
1
+ import { V as ViteNodeRunner } from './chunk-vite-node-client.cddda63d.mjs';
2
2
  import { normalizePath } from 'vite';
3
- import { L as isWindows, M as mergeSlashes, d as dirname, j as join, y as basename, x as resolve, s as slash, k as getType, N as getAllMockableProperties } from './chunk-mock-date.debe9954.mjs';
3
+ import { C as isWindows, D as mergeSlashes, s as slash, h as getType, E as getAllMockableProperties } from './chunk-mock-date.304e29b1.mjs';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.d8e5ff7b.mjs';
6
- import { d as distDir } from './chunk-constants.d3f8437b.mjs';
5
+ import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.b432150c.mjs';
6
+ import { d as dirname, j as join, b as basename, a as resolve, c as distDir } from './chunk-constants.71e8a211.mjs';
7
7
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
8
8
 
9
9
  class RefTracker {
@@ -1,4 +1,4 @@
1
- import './chunk-mock-date.debe9954.mjs';
1
+ import './chunk-mock-date.304e29b1.mjs';
2
2
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
3
3
  import { w as withSafeTimers } from './chunk-utils-timers.b48455ed.mjs';
4
4
 
@@ -1,5 +1,5 @@
1
- import { s as slash, f as notNullish } from './chunk-mock-date.debe9954.mjs';
2
- import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
1
+ import { s as slash, e as notNullish } from './chunk-mock-date.304e29b1.mjs';
2
+ import { p as picocolors } from './chunk-constants.71e8a211.mjs';
3
3
 
4
4
  var build = {};
5
5
 
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath } from 'url';
3
3
  import vm from 'vm';
4
- import { x as resolve, d as dirname, z as isAbsolute, K as extname } from './chunk-mock-date.debe9954.mjs';
5
- import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.d8e5ff7b.mjs';
4
+ import { a as resolve, d as dirname, i as isAbsolute, h as extname } from './chunk-constants.71e8a211.mjs';
5
+ import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.b432150c.mjs';
6
6
  import createDebug from 'debug';
7
7
 
8
8
  const debugExecute = createDebug("vite-node:client:execute");
@@ -45,7 +45,7 @@ class ModuleCacheMap extends Map {
45
45
  normalizePath(fsPath) {
46
46
  return normalizeModuleId(fsPath);
47
47
  }
48
- set(fsPath, mod) {
48
+ update(fsPath, mod) {
49
49
  fsPath = this.normalizePath(fsPath);
50
50
  if (!super.has(fsPath))
51
51
  super.set(fsPath, mod);
@@ -53,14 +53,33 @@ class ModuleCacheMap extends Map {
53
53
  Object.assign(super.get(fsPath), mod);
54
54
  return this;
55
55
  }
56
+ set(fsPath, mod) {
57
+ fsPath = this.normalizePath(fsPath);
58
+ return super.set(fsPath, mod);
59
+ }
56
60
  get(fsPath) {
57
61
  fsPath = this.normalizePath(fsPath);
62
+ if (!super.has(fsPath))
63
+ super.set(fsPath, {});
58
64
  return super.get(fsPath);
59
65
  }
60
66
  delete(fsPath) {
61
67
  fsPath = this.normalizePath(fsPath);
62
68
  return super.delete(fsPath);
63
69
  }
70
+ invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
71
+ for (const _id of ids) {
72
+ const id = this.normalizePath(_id);
73
+ if (invalidated.has(id))
74
+ continue;
75
+ invalidated.add(id);
76
+ const mod = super.get(id);
77
+ if (mod == null ? void 0 : mod.importers)
78
+ this.invalidateDepTree(mod.importers, invalidated);
79
+ super.delete(id);
80
+ }
81
+ return invalidated;
82
+ }
64
83
  }
65
84
  class ViteNodeRunner {
66
85
  constructor(options) {
@@ -76,39 +95,44 @@ class ViteNodeRunner {
76
95
  return await this.cachedRequest(id, []);
77
96
  }
78
97
  async cachedRequest(rawId, callstack) {
79
- var _a, _b, _c, _d;
80
98
  const id = normalizeRequestId(rawId, this.options.base);
81
99
  const fsPath = toFilePath(id, this.root);
82
- if (callstack.includes(fsPath) && ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.exports))
83
- return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.exports;
84
- if ((_c = this.moduleCache.get(fsPath)) == null ? void 0 : _c.promise)
85
- return (_d = this.moduleCache.get(fsPath)) == null ? void 0 : _d.promise;
100
+ const mod = this.moduleCache.get(fsPath);
101
+ const importee = callstack[callstack.length - 1];
102
+ if (!mod.importers)
103
+ mod.importers = /* @__PURE__ */ new Set();
104
+ if (importee)
105
+ mod.importers.add(importee);
106
+ if (callstack.includes(fsPath) && mod.exports)
107
+ return mod.exports;
108
+ if (mod.promise)
109
+ return mod.promise;
86
110
  const promise = this.directRequest(id, fsPath, callstack);
87
- this.moduleCache.set(fsPath, { promise });
111
+ Object.assign(mod, { promise });
88
112
  return await promise;
89
113
  }
90
114
  async directRequest(id, fsPath, _callstack) {
91
115
  const callstack = [..._callstack, fsPath];
116
+ const mod = this.moduleCache.get(fsPath);
92
117
  const request = async (dep) => {
93
118
  var _a;
94
- const fsPath2 = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
119
+ const depFsPath = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
95
120
  const getStack = () => {
96
121
  return `stack:
97
- ${[...callstack, fsPath2].reverse().map((p) => `- ${p}`).join("\n")}`;
122
+ ${[...callstack, depFsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
98
123
  };
99
124
  let debugTimer;
100
125
  if (this.debug)
101
- debugTimer = setTimeout(() => console.warn(() => `module ${fsPath2} takes over 2s to load.
126
+ debugTimer = setTimeout(() => console.warn(() => `module ${depFsPath} takes over 2s to load.
102
127
  ${getStack()}`), 2e3);
103
128
  try {
104
- if (callstack.includes(fsPath2)) {
105
- const depExports = (_a = this.moduleCache.get(fsPath2)) == null ? void 0 : _a.exports;
129
+ if (callstack.includes(depFsPath)) {
130
+ const depExports = (_a = this.moduleCache.get(depFsPath)) == null ? void 0 : _a.exports;
106
131
  if (depExports)
107
132
  return depExports;
108
133
  throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
109
134
  }
110
- const mod = await this.cachedRequest(dep, callstack);
111
- return mod;
135
+ return await this.cachedRequest(dep, callstack);
112
136
  } finally {
113
137
  if (debugTimer)
114
138
  clearTimeout(debugTimer);
@@ -132,9 +156,9 @@ ${getStack()}`), 2e3);
132
156
  let { code: transformed, externalize } = await this.options.fetchModule(id);
133
157
  if (externalize) {
134
158
  debugNative(externalize);
135
- const mod = await this.interopedImport(externalize);
136
- this.moduleCache.set(fsPath, { exports: mod });
137
- return mod;
159
+ const exports2 = await this.interopedImport(externalize);
160
+ mod.exports = exports2;
161
+ return exports2;
138
162
  }
139
163
  if (transformed == null)
140
164
  throw new Error(`[vite-node] Failed to load ${id}`);
@@ -146,7 +170,7 @@ ${getStack()}`), 2e3);
146
170
  enumerable: false,
147
171
  configurable: false
148
172
  });
149
- this.moduleCache.set(fsPath, { code: transformed, exports });
173
+ Object.assign(mod, { code: transformed, exports });
150
174
  const __filename = fileURLToPath(url);
151
175
  const moduleProxy = {
152
176
  set exports(value) {
@@ -1,9 +1,8 @@
1
1
  import { existsSync, promises } from 'fs';
2
- import { x as resolve, j as join } from './chunk-mock-date.debe9954.mjs';
3
- import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
4
- import 'path';
5
- import 'local-pkg';
2
+ import { a as resolve, p as picocolors, j as join } from './chunk-constants.71e8a211.mjs';
6
3
  import 'tty';
4
+ import 'url';
5
+ import 'path';
7
6
 
8
7
  function hashCode(s) {
9
8
  return s.split("").reduce((a, b) => {
@@ -1,24 +1,23 @@
1
- import { x as resolve, j as join, y as basename, d as dirname, A as AggregateErrorPonyfill, z as isAbsolute, B as relative, s as slash$2, l as isNode, o as relativePath, C as getTests, e as getFullName, w as hasFailed, D as hasFailedSnapshot, E as getSuites, u as shuffle, t as toArray$1, F as normalize, n as noop$1, G as deepMerge, H as toNamespacedPath, g as getCallLastIndex, f as notNullish, I as ensurePackageInstalled, J as stdout } from './chunk-mock-date.debe9954.mjs';
1
+ import { a as resolve, j as join, b as basename, d as dirname, c as distDir, e as rootDir, p as picocolors, i as isAbsolute, r as relative, f as configFiles, g as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-constants.71e8a211.mjs';
2
2
  import { p as pLimit, g as getCoverageProvider, a as envPackageNames, C as CoverageProviderMap } from './chunk-integrations-coverage.d205bd87.mjs';
3
- import { loadConfigFromFile, createServer, mergeConfig } from 'vite';
3
+ import { A as AggregateErrorPonyfill, s as slash$2, j as isNode, k as relativePath, v as getTests, d as getFullName, u as hasFailed, w as hasFailedSnapshot, x as getSuites, o as shuffle, t as toArray$1, n as noop$1, y as deepMerge, g as getCallLastIndex, e as notNullish, z as ensurePackageInstalled, B as stdout } from './chunk-mock-date.304e29b1.mjs';
4
+ import { loadConfigFromFile, normalizePath, createServer, mergeConfig } from 'vite';
4
5
  import path$a from 'path';
5
6
  import url, { fileURLToPath } from 'url';
6
7
  import process$1 from 'process';
7
8
  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.d3f8437b.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 { p as picocolors } from './vendor-picocolors.807856aa.mjs';
15
- import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.d1ead698.mjs';
14
+ import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.cddda63d.mjs';
15
+ import { performance } from 'perf_hooks';
16
16
  import createDebug from 'debug';
17
- 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.d8e5ff7b.mjs';
17
+ 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.b432150c.mjs';
18
18
  import { MessageChannel } from 'worker_threads';
19
19
  import { Tinypool } from 'tinypool';
20
- import { performance } from 'perf_hooks';
21
- 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.2a082ffd.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.bbf3ad19.mjs';
22
21
  import { b as safeSetInterval, c as safeClearInterval, s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
23
22
  import { resolveModule } from 'local-pkg';
24
23
  import { createHash } from 'crypto';
@@ -28,7 +27,7 @@ import MagicString from './chunk-magic-string.efe26975.mjs';
28
27
  import require$$0$2 from 'readline';
29
28
  import { p as prompts } from './vendor-index.ae96af6e.mjs';
30
29
 
31
- var version$1 = "0.22.0";
30
+ var version$1 = "0.22.1";
32
31
 
33
32
  class EndError extends Error {
34
33
  constructor(value) {
@@ -6852,7 +6851,7 @@ class ViteNodeServer {
6852
6851
  }, options.debug ?? {});
6853
6852
  }
6854
6853
  if (options.debug)
6855
- import('./chunk-vite-node-debug.ff1d2a9f.mjs').then((r) => this.debugger = new r.Debugger(server.config.root, options.debug));
6854
+ import('./chunk-vite-node-debug.536c4c5b.mjs').then((r) => this.debugger = new r.Debugger(server.config.root, options.debug));
6856
6855
  }
6857
6856
  shouldExternalize(id) {
6858
6857
  return shouldExternalize(id, this.options.deps, this.externalizeCache);
@@ -6902,14 +6901,18 @@ class ViteNodeServer {
6902
6901
  if (timestamp && cache && cache.timestamp >= timestamp)
6903
6902
  return cache.result;
6904
6903
  const externalize = await this.shouldExternalize(filePath);
6904
+ let duration;
6905
6905
  if (externalize) {
6906
6906
  result = { externalize };
6907
6907
  (_a = this.debugger) == null ? void 0 : _a.recordExternalize(id, externalize);
6908
6908
  } else {
6909
+ const start = performance.now();
6909
6910
  const r = await this._transformRequest(id);
6911
+ duration = performance.now() - start;
6910
6912
  result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
6911
6913
  }
6912
6914
  this.fetchCache.set(filePath, {
6915
+ duration,
6913
6916
  timestamp,
6914
6917
  result
6915
6918
  });
@@ -7455,8 +7458,8 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7455
7458
  return shouldIgnore;
7456
7459
  return true;
7457
7460
  }
7458
- onServerRestart() {
7459
- this.ctx.logger.log(picocolors.exports.cyan("Restarted due to config changes..."));
7461
+ onServerRestart(reason) {
7462
+ this.ctx.logger.log(picocolors.exports.bold(picocolors.exports.magenta(reason === "config" ? "\nRestarting due to config changes..." : "\nRestarting Vitest...")));
7460
7463
  }
7461
7464
  async reportSummary(files) {
7462
7465
  const logger = this.ctx.logger;
@@ -7491,6 +7494,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7491
7494
  var _a2;
7492
7495
  return acc + Math.max(0, ((_a2 = test.result) == null ? void 0 : _a2.duration) || 0);
7493
7496
  }, 0);
7497
+ const transformTime = Array.from(this.ctx.vitenode.fetchCache.values()).reduce((a, b) => a + ((b == null ? void 0 : b.duration) || 0), 0);
7494
7498
  const threadTime = collectTime + testsTime + setupTime;
7495
7499
  const padTitle = (str) => picocolors.exports.dim(`${str.padStart(10)} `);
7496
7500
  const time = (time2) => {
@@ -7510,7 +7514,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7510
7514
  if (this.watchFilters)
7511
7515
  logger.log(padTitle("Duration"), time(threadTime));
7512
7516
  else
7513
- logger.log(padTitle("Duration"), time(executionTime) + picocolors.exports.gray(` (setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
7517
+ logger.log(padTitle("Duration"), time(executionTime) + picocolors.exports.dim(` (transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
7514
7518
  logger.log();
7515
7519
  }
7516
7520
  async printTaskErrors(tasks, errorDivider) {
@@ -9190,7 +9194,7 @@ createLogUpdate(process$1.stdout);
9190
9194
 
9191
9195
  createLogUpdate(process$1.stderr);
9192
9196
 
9193
- var version = "0.22.0";
9197
+ var version = "0.22.1";
9194
9198
 
9195
9199
  function fileFromParsedStack(stack) {
9196
9200
  var _a, _b;
@@ -9496,9 +9500,23 @@ class Vitest {
9496
9500
  return node.resolveId(id, importer);
9497
9501
  }
9498
9502
  });
9503
+ if (this.config.watch) {
9504
+ const serverRestart = server.restart;
9505
+ server.restart = async (...args) => {
9506
+ await Promise.all(this._onRestartListeners.map((fn) => fn()));
9507
+ return await serverRestart(...args);
9508
+ };
9509
+ server.watcher.on("change", async (file) => {
9510
+ file = normalizePath(file);
9511
+ const isConfig = file === server.config.configFile;
9512
+ if (isConfig) {
9513
+ await Promise.all(this._onRestartListeners.map((fn) => fn("config")));
9514
+ await serverRestart();
9515
+ }
9516
+ });
9517
+ }
9499
9518
  this.reporters = await createReporters(resolved.reporters, this.runner);
9500
9519
  this.runningPromise = void 0;
9501
- this._onRestartListeners.forEach((fn) => fn());
9502
9520
  await ((_c = this.coverageProvider) == null ? void 0 : _c.clean(this.config.coverage.clean));
9503
9521
  this.cache.results.setConfig(resolved.root, resolved.cache);
9504
9522
  try {
@@ -9576,7 +9594,7 @@ class Vitest {
9576
9594
  }
9577
9595
  async filterTestsBySource(tests) {
9578
9596
  if (this.config.changed && !this.config.related) {
9579
- const { VitestGit } = await import('./chunk-node-git.71b74da4.mjs');
9597
+ const { VitestGit } = await import('./chunk-node-git.9a7e3153.mjs');
9580
9598
  const vitestGit = new VitestGit(this.config.root);
9581
9599
  const related2 = await vitestGit.findChangedFiles({
9582
9600
  changedSince: this.config.changed
@@ -9828,7 +9846,7 @@ class Vitest {
9828
9846
  isInSourceTestFile(code) {
9829
9847
  return code.includes("import.meta.vitest");
9830
9848
  }
9831
- onServerRestarted(fn) {
9849
+ onServerRestart(fn) {
9832
9850
  this._onRestartListeners.push(fn);
9833
9851
  }
9834
9852
  }
@@ -10073,7 +10091,6 @@ function CoverageTransform(ctx) {
10073
10091
  }
10074
10092
 
10075
10093
  async function VitestPlugin(options = {}, ctx = new Vitest()) {
10076
- let haveStarted = false;
10077
10094
  async function UIPlugin() {
10078
10095
  var _a;
10079
10096
  await ensurePackageInstalled("@vitest/ui", ((_a = ctx.config) == null ? void 0 : _a.root) || options.root || process.cwd());
@@ -10169,13 +10186,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10169
10186
  (_d = process.env)[name] ?? (_d[name] = envs[name]);
10170
10187
  },
10171
10188
  async configureServer(server) {
10172
- if (haveStarted)
10173
- await ctx.report("onServerRestart");
10174
10189
  try {
10175
10190
  await ctx.setServer(options, server);
10176
- haveStarted = true;
10177
10191
  if (options.api && options.watch)
10178
- (await import('./chunk-api-setup.ecd02c18.mjs')).setup(ctx);
10192
+ (await import('./chunk-api-setup.377c28aa.mjs')).setup(ctx);
10179
10193
  } catch (err) {
10180
10194
  ctx.logger.printError(err, true);
10181
10195
  process.exit(1);
@@ -10315,8 +10329,12 @@ async function startVitest(cliFilters, options, viteOverrides) {
10315
10329
  }
10316
10330
  if (process.stdin.isTTY && ctx.config.watch)
10317
10331
  registerConsoleShortcuts(ctx);
10318
- ctx.onServerRestarted(() => {
10319
- ctx.start(cliFilters);
10332
+ ctx.onServerRestart((reason) => {
10333
+ ctx.report("onServerRestart", reason);
10334
+ if (process.env.VITEST_CLI_WRAPPER)
10335
+ process.exit(EXIT_CODE_RESTART);
10336
+ else
10337
+ ctx.start(cliFilters);
10320
10338
  });
10321
10339
  try {
10322
10340
  await ctx.start(cliFilters);
@@ -4,7 +4,7 @@ import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'u
4
4
  import path from 'path';
5
5
  import assert from 'assert';
6
6
  import { format, inspect } from 'util';
7
- import { x as resolve$1 } from './chunk-mock-date.debe9954.mjs';
7
+ import { a as resolve$1 } from './chunk-constants.71e8a211.mjs';
8
8
 
9
9
  // This file was generated. Do not modify manually!
10
10
  var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
@@ -1,9 +1,9 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
2
+ import { p as picocolors, E as EXIT_CODE_RESTART } from './chunk-constants.71e8a211.mjs';
3
3
  import { e as execa } from './vendor-index.fbec8a81.mjs';
4
4
  import 'tty';
5
- import 'buffer';
6
5
  import 'path';
6
+ import 'buffer';
7
7
  import 'child_process';
8
8
  import 'process';
9
9
  import './vendor-index.2ae8040a.mjs';
@@ -17,8 +17,12 @@ import 'assert';
17
17
  import 'events';
18
18
 
19
19
  const ENTRY = new URL("./cli.mjs", import.meta.url);
20
- const NODE_ARGS = ["--inspect", "--inspect-brk", "--trace-deprecation"];
21
- const ERRORS = [
20
+ const NODE_ARGS = [
21
+ "--inspect",
22
+ "--inspect-brk",
23
+ "--trace-deprecation"
24
+ ];
25
+ const SegfaultErrors = [
22
26
  {
23
27
  trigger: "Check failed: result.second.",
24
28
  url: "https://github.com/nodejs/node/issues/43617"
@@ -32,9 +36,9 @@ const ERRORS = [
32
36
  url: "https://github.com/nodejs/node/issues/42407"
33
37
  }
34
38
  ];
39
+ main();
35
40
  async function main() {
36
41
  var _a;
37
- const exitCode = 100;
38
42
  let retries = 0;
39
43
  const args = process.argv.slice(2);
40
44
  if (process.env.VITEST_SEGFAULT_RETRY) {
@@ -50,23 +54,6 @@ async function main() {
50
54
  }
51
55
  }
52
56
  }
53
- retries = Math.max(1, retries || 1);
54
- for (let i = 1; i <= retries; i++) {
55
- if (i !== 1)
56
- console.log(`${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.magenta(" Retrying ")))} vitest ${args.join(" ")} ${picocolors.exports.gray(`(${i} of ${retries})`)}`);
57
- await start(args);
58
- if (i === 1 && retries === 1) {
59
- console.log(picocolors.exports.yellow(`It seems to be an upstream bug of Node.js. To improve the test stability,
60
- you could pass ${picocolors.exports.bold(picocolors.exports.green("--segfault-retry=3"))} or set env ${picocolors.exports.bold(picocolors.exports.green("VITEST_SEGFAULT_RETRY=3"))} to
61
- have Vitest auto retries on flaky segfaults.
62
- `));
63
- }
64
- }
65
- process.exit(exitCode);
66
- }
67
- main();
68
- async function start(args) {
69
- var _a;
70
57
  const nodeArgs = [];
71
58
  const vitestArgs = [];
72
59
  for (let i = 0; i < args.length; i++) {
@@ -81,15 +68,45 @@ async function start(args) {
81
68
  if (!matched)
82
69
  vitestArgs.push(args[i]);
83
70
  }
84
- const child = execa("node", [...nodeArgs, fileURLToPath(ENTRY), ...vitestArgs], {
71
+ retries = Math.max(1, retries || 1);
72
+ for (let i = 1; i <= retries; i++) {
73
+ const result = await start(nodeArgs, vitestArgs);
74
+ if (result === "restart") {
75
+ i -= 1;
76
+ continue;
77
+ }
78
+ if (i === 1 && retries === 1) {
79
+ console.log(picocolors.exports.yellow(`It seems to be an upstream bug of Node.js. To improve the test stability,
80
+ you could pass ${picocolors.exports.bold(picocolors.exports.green("--segfault-retry=3"))} or set env ${picocolors.exports.bold(picocolors.exports.green("VITEST_SEGFAULT_RETRY=3"))} to
81
+ have Vitest auto retries on flaky segfaults.
82
+ `));
83
+ }
84
+ if (i !== retries)
85
+ console.log(`${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.magenta(" Retrying ")))} vitest ${args.join(" ")} ${picocolors.exports.gray(`(${i + 1} of ${retries})`)}`);
86
+ }
87
+ process.exit(1);
88
+ }
89
+ async function start(preArgs, postArgs) {
90
+ var _a;
91
+ const child = execa("node", [
92
+ ...preArgs,
93
+ fileURLToPath(ENTRY),
94
+ ...postArgs
95
+ ], {
85
96
  reject: false,
86
97
  stderr: "pipe",
87
98
  stdout: "inherit",
88
- stdin: "inherit"
99
+ stdin: "inherit",
100
+ env: {
101
+ ...process.env,
102
+ VITEST_CLI_WRAPPER: "true"
103
+ }
89
104
  });
90
105
  (_a = child.stderr) == null ? void 0 : _a.pipe(process.stderr);
91
106
  const { stderr = "" } = await child;
92
- for (const error of ERRORS) {
107
+ if (child.exitCode === EXIT_CODE_RESTART)
108
+ return "restart";
109
+ for (const error of SegfaultErrors) {
93
110
  if (stderr.includes(error.trigger)) {
94
111
  if (process.env.GITHUB_ACTIONS)
95
112
  console.log(`::warning:: Segmentfault Error Detected: ${error.trigger}
@@ -100,7 +117,7 @@ ${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.red(" Se
100
117
  ${RED_BLOCK} ${picocolors.exports.red(error.trigger)}
101
118
  ${RED_BLOCK} ${picocolors.exports.red(`Refer to ${error.url}`)}
102
119
  `);
103
- return;
120
+ return "error";
104
121
  }
105
122
  }
106
123
  process.exit(child.exitCode);
package/dist/cli.mjs CHANGED
@@ -1,30 +1,29 @@
1
1
  import { EventEmitter } from 'events';
2
- import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.3a38c8af.mjs';
2
+ import { p as picocolors } from './chunk-constants.71e8a211.mjs';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.c843f497.mjs';
4
4
  import 'tty';
5
- import './chunk-mock-date.debe9954.mjs';
5
+ import 'url';
6
6
  import 'path';
7
- import 'local-pkg';
8
7
  import './chunk-integrations-coverage.d205bd87.mjs';
8
+ import 'local-pkg';
9
+ import './chunk-mock-date.304e29b1.mjs';
9
10
  import 'vite';
10
- import 'url';
11
11
  import 'process';
12
12
  import 'fs';
13
- import './chunk-constants.d3f8437b.mjs';
14
13
  import 'os';
15
14
  import 'util';
16
15
  import 'stream';
17
16
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
18
- import './chunk-vite-node-client.d1ead698.mjs';
17
+ import './chunk-vite-node-client.cddda63d.mjs';
19
18
  import 'module';
20
19
  import 'vm';
21
- import './chunk-vite-node-utils.d8e5ff7b.mjs';
20
+ import './chunk-vite-node-utils.b432150c.mjs';
22
21
  import 'assert';
23
22
  import 'debug';
23
+ import 'perf_hooks';
24
24
  import 'worker_threads';
25
25
  import 'tinypool';
26
- import 'perf_hooks';
27
- import './chunk-utils-source-map.2a082ffd.mjs';
26
+ import './chunk-utils-source-map.bbf3ad19.mjs';
28
27
  import './chunk-utils-timers.b48455ed.mjs';
29
28
  import 'crypto';
30
29
  import './vendor-index.9d9196cc.mjs';
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv } from 'vite';
3
- import { U as UserConfig$1, a8 as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './global-74489cc9.js';
3
+ import { U as UserConfig$1, a9 as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './global-fe52f84b.js';
4
4
  import 'worker_threads';
5
5
  import 'fs';
6
6
 
package/dist/entry.mjs CHANGED
@@ -1,20 +1,21 @@
1
1
  import { promises } from 'fs';
2
- import { a as resetModules } from './chunk-mock-date.debe9954.mjs';
2
+ import { a as resetModules } from './chunk-mock-date.304e29b1.mjs';
3
3
  import { b as envs } from './chunk-integrations-coverage.d205bd87.mjs';
4
- import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.975bd80a.mjs';
4
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.1104e45a.mjs';
5
5
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
6
6
  import 'path';
7
- import './vendor-picocolors.807856aa.mjs';
7
+ import './chunk-constants.71e8a211.mjs';
8
8
  import 'tty';
9
+ import 'url';
9
10
  import 'local-pkg';
10
- import './chunk-runtime-hooks.4789e99d.mjs';
11
- import './chunk-runtime-chain.6e363ba2.mjs';
11
+ import './chunk-runtime-hooks.5d7073db.mjs';
12
+ import './chunk-runtime-chain.be610650.mjs';
12
13
  import 'util';
13
14
  import 'chai';
14
15
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
15
- import './chunk-runtime-rpc.29488183.mjs';
16
+ import './chunk-runtime-rpc.57586b73.mjs';
16
17
  import './chunk-utils-timers.b48455ed.mjs';
17
- import './chunk-utils-source-map.2a082ffd.mjs';
18
+ import './chunk-utils-source-map.bbf3ad19.mjs';
18
19
  import './spy.mjs';
19
20
  import 'tinyspy';
20
21