vitest 0.22.0 → 0.23.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 (49) hide show
  1. package/LICENSE.md +29 -29
  2. package/dist/browser.d.ts +5 -4
  3. package/dist/browser.mjs +12 -9
  4. package/dist/{chunk-api-setup.ecd02c18.mjs → chunk-api-setup.9e83ca0a.mjs} +92 -90
  5. package/dist/chunk-constants.6196597b.mjs +284 -0
  6. package/dist/{chunk-integrations-coverage.d205bd87.mjs → chunk-env-node.ceb43f1c.mjs} +31 -179
  7. package/dist/{chunk-install-pkg.3aa3eae6.mjs → chunk-install-pkg.e081fc1b.mjs} +3 -3
  8. package/dist/chunk-integrations-coverage.99c020eb.mjs +166 -0
  9. package/dist/chunk-integrations-globals.b1aa52c3.mjs +25 -0
  10. package/dist/{chunk-magic-string.efe26975.mjs → chunk-magic-string.56b2b543.mjs} +30 -10
  11. package/dist/{chunk-mock-date.debe9954.mjs → chunk-mock-date.f63a5ff2.mjs} +31 -193
  12. package/dist/{chunk-node-git.71b74da4.mjs → chunk-node-git.6f289b0a.mjs} +20 -16
  13. package/dist/{chunk-runtime-chain.6e363ba2.mjs → chunk-runtime-chain.8bfc559b.mjs} +507 -173
  14. package/dist/{chunk-runtime-error.975bd80a.mjs → chunk-runtime-error.252dd130.mjs} +206 -75
  15. package/dist/{chunk-runtime-hooks.4789e99d.mjs → chunk-runtime-hooks.c6b06bd8.mjs} +18 -12
  16. package/dist/{chunk-runtime-mocker.c91d29ce.mjs → chunk-runtime-mocker.d9690273.mjs} +19 -12
  17. package/dist/{chunk-runtime-rpc.29488183.mjs → chunk-runtime-rpc.48bd94e3.mjs} +1 -2
  18. package/dist/{chunk-utils-source-map.2a082ffd.mjs → chunk-utils-source-map.a1647f5f.mjs} +11 -5
  19. package/dist/{chunk-vite-node-client.d1ead698.mjs → chunk-vite-node-client.998e04d0.mjs} +92 -31
  20. package/dist/{chunk-vite-node-debug.ff1d2a9f.mjs → chunk-vite-node-debug.2d8a1dc3.mjs} +3 -4
  21. package/dist/{chunk-vite-node-externalize.3a38c8af.mjs → chunk-vite-node-externalize.3035bd5b.mjs} +515 -211
  22. package/dist/{chunk-vite-node-utils.d8e5ff7b.mjs → chunk-vite-node-utils.8a9b3014.mjs} +39 -41
  23. package/dist/cli-wrapper.mjs +54 -33
  24. package/dist/cli.mjs +31 -20
  25. package/dist/config.cjs +2 -2
  26. package/dist/config.d.ts +4 -3
  27. package/dist/config.mjs +2 -2
  28. package/dist/entry.mjs +20 -14
  29. package/dist/environments.d.ts +23 -0
  30. package/dist/environments.mjs +3 -0
  31. package/dist/{global-74489cc9.d.ts → global-ea084c9f.d.ts} +154 -24
  32. package/dist/{index-9eded9ec.d.ts → index-5f09f4d0.d.ts} +3 -2
  33. package/dist/index.d.ts +6 -5
  34. package/dist/index.mjs +7 -7
  35. package/dist/loader.mjs +5 -6
  36. package/dist/node.d.ts +5 -4
  37. package/dist/node.mjs +17 -16
  38. package/dist/suite.mjs +6 -6
  39. package/dist/vendor-index.0557b03a.mjs +147 -0
  40. package/dist/{vendor-index.9d9196cc.mjs → vendor-index.13e3bda3.mjs} +0 -0
  41. package/dist/{vendor-index.fbec8a81.mjs → vendor-index.4aeeb598.mjs} +2 -2
  42. package/dist/{vendor-index.2ae8040a.mjs → vendor-index.62ce5c33.mjs} +0 -0
  43. package/dist/{vendor-index.29636037.mjs → vendor-index.731a22f2.mjs} +0 -0
  44. package/dist/worker.mjs +20 -19
  45. package/package.json +18 -11
  46. package/dist/chunk-constants.d3f8437b.mjs +0 -38
  47. package/dist/chunk-integrations-globals.e81d2091.mjs +0 -27
  48. package/dist/chunk-utils-global.fa20c2f6.mjs +0 -5
  49. package/dist/vendor-picocolors.807856aa.mjs +0 -64
@@ -1,190 +1,7 @@
1
- import path, { relative as relative$1 } from 'path';
2
- import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
1
+ import { relative } from 'path';
2
+ import { r as relative$1, p as picocolors, E as EXIT_CODE_RESTART } from './chunk-constants.6196597b.mjs';
3
3
  import { isPackageExists } from 'local-pkg';
4
4
 
5
- function normalizeWindowsPath(input = "") {
6
- if (!input.includes("\\")) {
7
- return input;
8
- }
9
- return input.replace(/\\/g, "/");
10
- }
11
-
12
- const _UNC_REGEX = /^[/][/]/;
13
- const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
14
- const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
15
- const sep = "/";
16
- const delimiter = ":";
17
- const normalize = function(path2) {
18
- if (path2.length === 0) {
19
- return ".";
20
- }
21
- path2 = normalizeWindowsPath(path2);
22
- const isUNCPath = path2.match(_UNC_REGEX);
23
- const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
24
- const isPathAbsolute = isAbsolute(path2);
25
- const trailingSeparator = path2[path2.length - 1] === "/";
26
- path2 = normalizeString(path2, !isPathAbsolute);
27
- if (path2.length === 0) {
28
- if (isPathAbsolute) {
29
- return "/";
30
- }
31
- return trailingSeparator ? "./" : ".";
32
- }
33
- if (trailingSeparator) {
34
- path2 += "/";
35
- }
36
- if (isUNCPath) {
37
- if (hasUNCDrive) {
38
- return `//./${path2}`;
39
- }
40
- return `//${path2}`;
41
- }
42
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
43
- };
44
- const join = function(...args) {
45
- if (args.length === 0) {
46
- return ".";
47
- }
48
- let joined;
49
- for (let i = 0; i < args.length; ++i) {
50
- const arg = args[i];
51
- if (arg.length > 0) {
52
- if (joined === void 0) {
53
- joined = arg;
54
- } else {
55
- joined += `/${arg}`;
56
- }
57
- }
58
- }
59
- if (joined === void 0) {
60
- return ".";
61
- }
62
- return normalize(joined);
63
- };
64
- const resolve = function(...args) {
65
- args = args.map((arg) => normalizeWindowsPath(arg));
66
- let resolvedPath = "";
67
- let resolvedAbsolute = false;
68
- for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
69
- const path2 = i >= 0 ? args[i] : process.cwd();
70
- if (path2.length === 0) {
71
- continue;
72
- }
73
- resolvedPath = `${path2}/${resolvedPath}`;
74
- resolvedAbsolute = isAbsolute(path2);
75
- }
76
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
77
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
78
- return `/${resolvedPath}`;
79
- }
80
- return resolvedPath.length > 0 ? resolvedPath : ".";
81
- };
82
- function normalizeString(path2, allowAboveRoot) {
83
- let res = "";
84
- let lastSegmentLength = 0;
85
- let lastSlash = -1;
86
- let dots = 0;
87
- let char = null;
88
- for (let i = 0; i <= path2.length; ++i) {
89
- if (i < path2.length) {
90
- char = path2[i];
91
- } else if (char === "/") {
92
- break;
93
- } else {
94
- char = "/";
95
- }
96
- if (char === "/") {
97
- if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
98
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
99
- if (res.length > 2) {
100
- const lastSlashIndex = res.lastIndexOf("/");
101
- if (lastSlashIndex === -1) {
102
- res = "";
103
- lastSegmentLength = 0;
104
- } else {
105
- res = res.slice(0, lastSlashIndex);
106
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
107
- }
108
- lastSlash = i;
109
- dots = 0;
110
- continue;
111
- } else if (res.length !== 0) {
112
- res = "";
113
- lastSegmentLength = 0;
114
- lastSlash = i;
115
- dots = 0;
116
- continue;
117
- }
118
- }
119
- if (allowAboveRoot) {
120
- res += res.length > 0 ? "/.." : "..";
121
- lastSegmentLength = 2;
122
- }
123
- } else {
124
- if (res.length > 0) {
125
- res += `/${path2.slice(lastSlash + 1, i)}`;
126
- } else {
127
- res = path2.slice(lastSlash + 1, i);
128
- }
129
- lastSegmentLength = i - lastSlash - 1;
130
- }
131
- lastSlash = i;
132
- dots = 0;
133
- } else if (char === "." && dots !== -1) {
134
- ++dots;
135
- } else {
136
- dots = -1;
137
- }
138
- }
139
- return res;
140
- }
141
- const isAbsolute = function(p) {
142
- return _IS_ABSOLUTE_RE.test(p);
143
- };
144
- const toNamespacedPath = function(p) {
145
- return normalizeWindowsPath(p);
146
- };
147
- const extname = function(p) {
148
- return path.posix.extname(normalizeWindowsPath(p));
149
- };
150
- const relative = function(from, to) {
151
- return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
152
- };
153
- const dirname = function(p) {
154
- return path.posix.dirname(normalizeWindowsPath(p));
155
- };
156
- const format = function(p) {
157
- return normalizeWindowsPath(path.posix.format(p));
158
- };
159
- const basename = function(p, ext) {
160
- return path.posix.basename(normalizeWindowsPath(p), ext);
161
- };
162
- const parse = function(p) {
163
- return path.posix.parse(normalizeWindowsPath(p));
164
- };
165
-
166
- const _path = /*#__PURE__*/Object.freeze({
167
- __proto__: null,
168
- sep: sep,
169
- delimiter: delimiter,
170
- normalize: normalize,
171
- join: join,
172
- resolve: resolve,
173
- normalizeString: normalizeString,
174
- isAbsolute: isAbsolute,
175
- toNamespacedPath: toNamespacedPath,
176
- extname: extname,
177
- relative: relative,
178
- dirname: dirname,
179
- format: format,
180
- basename: basename,
181
- parse: parse
182
- });
183
-
184
- ({
185
- ..._path
186
- });
187
-
188
5
  const RealDate = Date;
189
6
  let now = null;
190
7
  class MockDate extends RealDate {
@@ -361,14 +178,17 @@ function shuffle(array, seed = RealDate.now()) {
361
178
  return array;
362
179
  }
363
180
 
181
+ function isAtomTest(s) {
182
+ return s.type === "test" || s.type === "benchmark";
183
+ }
364
184
  function getTests(suite) {
365
- return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c) => c.type === "test" ? [c] : getTests(c)));
185
+ return toArray(suite).flatMap((s) => isAtomTest(s) ? [s] : s.tasks.flatMap((c) => isAtomTest(c) ? [c] : getTests(c)));
366
186
  }
367
187
  function getSuites(suite) {
368
188
  return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
369
189
  }
370
190
  function hasTests(suite) {
371
- return toArray(suite).some((s) => s.tasks.some((c) => c.type === "test" || hasTests(c)));
191
+ return toArray(suite).some((s) => s.tasks.some((c) => isAtomTest(c) || hasTests(c)));
372
192
  }
373
193
  function hasFailed(suite) {
374
194
  return toArray(suite).some((s) => {
@@ -394,11 +214,18 @@ function getNames(task) {
394
214
  return names;
395
215
  }
396
216
 
217
+ function getWorkerState() {
218
+ return globalThis.__vitest_worker__;
219
+ }
220
+
397
221
  var _a;
398
222
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
399
223
  const isBrowser = typeof window !== "undefined";
400
- const isWindows = isNode && process.platform === "win32";
401
- const relativePath = isBrowser ? relative$1 : relative;
224
+ isNode && process.platform === "win32";
225
+ const getRunMode = () => getWorkerState().config.mode;
226
+ const isRunningInTest = () => getRunMode() === "test";
227
+ const isRunningInBenchmark = () => getRunMode() === "benchmark";
228
+ const relativePath = isBrowser ? relative : relative$1;
402
229
  function partitionSuiteChildren(suite) {
403
230
  let tasksGroup = [];
404
231
  const tasksGroups = [];
@@ -446,11 +273,11 @@ async function ensurePackageInstalled(dependency, root) {
446
273
  message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
447
274
  });
448
275
  if (install) {
449
- await (await import('./chunk-install-pkg.3aa3eae6.mjs')).installPackage(dependency, { dev: true });
276
+ await (await import('./chunk-install-pkg.e081fc1b.mjs')).installPackage(dependency, { dev: true });
450
277
  process.stderr.write(picocolors.exports.yellow(`
451
278
  Package ${dependency} installed, re-run the command to start.
452
279
  `));
453
- process.exit(1);
280
+ process.exit(EXIT_CODE_RESTART);
454
281
  return true;
455
282
  }
456
283
  return false;
@@ -483,12 +310,23 @@ function getCallLastIndex(code) {
483
310
  }
484
311
  return null;
485
312
  }
486
- isNode ? relative : relative$1;
313
+ isNode ? relative$1 : relative;
487
314
  class AggregateErrorPonyfill extends Error {
488
315
  constructor(errors, message = "") {
489
316
  super(message);
490
317
  this.errors = [...errors];
491
318
  }
492
319
  }
320
+ function createDefer() {
321
+ let resolve2 = null;
322
+ let reject = null;
323
+ const p = new Promise((_resolve, _reject) => {
324
+ resolve2 = _resolve;
325
+ reject = _reject;
326
+ });
327
+ p.resolve = resolve2;
328
+ p.reject = reject;
329
+ return p;
330
+ }
493
331
 
494
- export { AggregateErrorPonyfill as A, relative as B, getTests as C, hasFailedSnapshot as D, getSuites as E, normalize as F, deepMerge as G, toNamespacedPath as H, ensurePackageInstalled as I, stdout as J, extname as K, isWindows as L, mergeSlashes as M, getAllMockableProperties as N, RealDate as R, resetModules as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, notNullish as f, getCallLastIndex as g, deepClone as h, isObject as i, join as j, getType as k, isNode as l, mockDate as m, noop as n, relativePath as o, isBrowser as p, partitionSuiteChildren as q, resetDate as r, slash as s, toArray as t, shuffle as u, hasTests as v, hasFailed as w, resolve as x, basename as y, isAbsolute as z };
332
+ export { AggregateErrorPonyfill as A, hasFailedSnapshot as B, getSuites as C, deepMerge as D, ensurePackageInstalled as E, stdout as F, mergeSlashes as G, getAllMockableProperties as H, RealDate as R, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, deepClone as k, getType as l, mockDate as m, noop as n, isNode as o, relativePath as p, isBrowser as q, resetDate as r, slash as s, toArray as t, partitionSuiteChildren as u, shuffle as v, hasTests as w, hasFailed as x, createDefer as y, getTests as z };
@@ -1,20 +1,18 @@
1
- import { x as resolve } from './chunk-mock-date.debe9954.mjs';
2
- import { e as execa } from './vendor-index.fbec8a81.mjs';
3
- import 'path';
4
- import './vendor-picocolors.807856aa.mjs';
1
+ import { a as resolve } from './chunk-constants.6196597b.mjs';
2
+ import { e as execa } from './vendor-index.4aeeb598.mjs';
5
3
  import 'tty';
6
- import 'local-pkg';
4
+ import 'url';
5
+ import 'path';
7
6
  import 'buffer';
8
7
  import 'child_process';
9
8
  import 'process';
10
- import './vendor-index.2ae8040a.mjs';
9
+ import './vendor-index.62ce5c33.mjs';
11
10
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
11
  import 'fs';
13
12
  import 'stream';
14
13
  import 'util';
15
- import 'url';
16
14
  import 'os';
17
- import './vendor-index.29636037.mjs';
15
+ import './vendor-index.731a22f2.mjs';
18
16
  import 'assert';
19
17
  import 'events';
20
18
 
@@ -53,18 +51,24 @@ class VitestGit {
53
51
  return [...staged, ...unstaged];
54
52
  }
55
53
  getFilesSince(hash) {
56
- return this.resolveFilesWithGitCommand(["diff", "--name-only", `${hash}...HEAD`]);
54
+ return this.resolveFilesWithGitCommand(
55
+ ["diff", "--name-only", `${hash}...HEAD`]
56
+ );
57
57
  }
58
58
  getStagedFiles() {
59
- return this.resolveFilesWithGitCommand(["diff", "--cached", "--name-only"]);
59
+ return this.resolveFilesWithGitCommand(
60
+ ["diff", "--cached", "--name-only"]
61
+ );
60
62
  }
61
63
  getUnstagedFiles() {
62
- return this.resolveFilesWithGitCommand([
63
- "ls-files",
64
- "--other",
65
- "--modified",
66
- "--exclude-standard"
67
- ]);
64
+ return this.resolveFilesWithGitCommand(
65
+ [
66
+ "ls-files",
67
+ "--other",
68
+ "--modified",
69
+ "--exclude-standard"
70
+ ]
71
+ );
68
72
  }
69
73
  async getRoot(cwd) {
70
74
  const options = ["rev-parse", "--show-cdup"];