vitest 1.5.0 → 1.5.2

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 (36) hide show
  1. package/dist/browser.d.ts +2 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{integrations-globals.2J_Aii2q.js → integrations-globals.k0N5-dd1.js} +2 -2
  4. package/dist/chunks/{runtime-runBaseTests.3fVSWBsC.js → runtime-runBaseTests.-x-nNuJ_.js} +4 -4
  5. package/dist/cli.js +2 -60
  6. package/dist/config.d.ts +2 -1
  7. package/dist/coverage.d.ts +4 -2
  8. package/dist/coverage.js +2 -2
  9. package/dist/environments.d.ts +2 -1
  10. package/dist/execute.d.ts +2 -1
  11. package/dist/index.d.ts +5 -4
  12. package/dist/index.js +3 -3
  13. package/dist/node.d.ts +26 -4
  14. package/dist/node.js +11 -9
  15. package/dist/{reporters-LqC_WI4d.d.ts → reporters-xEmem8D4.d.ts} +88 -41
  16. package/dist/reporters.d.ts +2 -1
  17. package/dist/reporters.js +3 -2
  18. package/dist/runners.d.ts +2 -1
  19. package/dist/runners.js +1 -1
  20. package/dist/{suite-ynYMzeLu.d.ts → suite-HPAKvIxA.d.ts} +1 -1
  21. package/dist/suite.d.ts +3 -2
  22. package/dist/vendor/{base.BjeeYg4o.js → base.gAwDs8Jc.js} +1 -1
  23. package/dist/vendor/cac.8mXc9Oj6.js +1406 -0
  24. package/dist/vendor/{cac.qnW6GNL2.js → cli-api._n4_Wp_j.js} +139 -1542
  25. package/dist/vendor/{index.12jbrDSD.js → index.0RrMQKD8.js} +1 -1
  26. package/dist/vendor/{index.kSaPvGW6.js → index.GlXSU9xI.js} +21 -208
  27. package/dist/vendor/{index.-ITFwqG_.js → index.gHZzsRJQ.js} +1 -1
  28. package/dist/vendor/{setup-common.A1De6efh.js → setup-common.7SXMSI--.js} +5 -2
  29. package/dist/vendor/utils.VYmeMh-u.js +217 -0
  30. package/dist/vendor/{vi.Fxjax7rQ.js → vi.Y_w82WR8.js} +5 -1
  31. package/dist/workers/forks.js +1 -1
  32. package/dist/workers/runVmTests.js +4 -4
  33. package/dist/workers/threads.js +1 -1
  34. package/dist/workers.d.ts +2 -1
  35. package/dist/workers.js +1 -1
  36. package/package.json +9 -9
@@ -1,7 +1,7 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
2
  import { b as bench } from './benchmark.eeqk2rd8.js';
3
3
  import { i as isFirstRun, a as runOnce } from './run-once.Olz_Zkd8.js';
4
- import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.Fxjax7rQ.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.Y_w82WR8.js';
5
5
  import { g as getWorkerState } from './global.CkGT_TMy.js';
6
6
  import * as chai from 'chai';
7
7
  import { assert, should } from 'chai';
@@ -1,18 +1,18 @@
1
1
  import { existsSync, promises, readFileSync } from 'node:fs';
2
- import { isAbsolute, relative, dirname, basename, resolve, join, extname, normalize } from 'pathe';
2
+ import { basename, dirname, resolve, join, relative, extname, normalize } from 'pathe';
3
3
  import { a as isNode, r as relativePath } from './index.ir9i0ywP.js';
4
4
  import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getTests, hasFailed, getSuites } from '@vitest/runner/utils';
5
5
  import c from 'picocolors';
6
+ import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, r as renderSnapshotSummary, a as getStateString, b as formatTimeString, c as countTestErrors, d as divider, s as stripAnsi, e as getCols, h as getHookStateSymbol, i as F_POINTER } from './utils.VYmeMh-u.js';
6
7
  import { getSafeTimers, notNullish, inspect, positionToOffset, lineSplitRE, highlight, shuffle } from '@vitest/utils';
7
8
  import { g as getFullName, h as hasFailedSnapshot } from './tasks.IknbGB2n.js';
8
9
  import { performance } from 'node:perf_hooks';
9
10
  import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.kbFEN7E-.js';
10
- import { a as slash, t as toArray, b as isPrimitive } from './base.Xt0Omgh7.js';
11
+ import { t as toArray, b as isPrimitive } from './base.Xt0Omgh7.js';
11
12
  import { isCI } from 'std-env';
12
13
  import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
13
14
  import nodeos__default, { hostname } from 'node:os';
14
15
  import { createRequire } from 'node:module';
15
- import { Console } from 'node:console';
16
16
  import { Writable } from 'node:stream';
17
17
  import { writeFile, rm } from 'node:fs/promises';
18
18
  import { execa } from 'execa';
@@ -22,204 +22,13 @@ import require$$0 from 'fs';
22
22
  import ge from 'module';
23
23
  import { parseAstAsync } from 'vite';
24
24
  import { ancestor } from 'acorn-walk';
25
+ import { Console } from 'node:console';
25
26
  import process$2 from 'node:process';
26
27
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.jjO7Zipk.js';
27
28
  import require$$0$2 from 'assert';
28
29
  import require$$0$1 from 'events';
29
30
  import { createHash } from 'node:crypto';
30
- import { slash as slash$1 } from 'vite-node/utils';
31
-
32
- function ansiRegex({onlyFirst = false} = {}) {
33
- const pattern = [
34
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
35
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
36
- ].join('|');
37
-
38
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
39
- }
40
-
41
- const regex = ansiRegex();
42
-
43
- function stripAnsi(string) {
44
- if (typeof string !== 'string') {
45
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
46
- }
47
-
48
- // Even though the regex is global, we don't need to reset the `.lastIndex`
49
- // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
50
- // and doing it manually has a performance penalty.
51
- return string.replace(regex, '');
52
- }
53
-
54
- const F_RIGHT = "\u2192";
55
- const F_DOWN = "\u2193";
56
- const F_DOWN_RIGHT = "\u21B3";
57
- const F_POINTER = "\u276F";
58
- const F_DOT = "\xB7";
59
- const F_CHECK = "\u2713";
60
- const F_CROSS = "\xD7";
61
- const F_LONG_DASH = "\u23AF";
62
-
63
- const spinnerMap = /* @__PURE__ */ new WeakMap();
64
- const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
65
- const pointer = c.yellow(F_POINTER);
66
- const skipped = c.dim(c.gray(F_DOWN));
67
- function getCols(delta = 0) {
68
- var _a;
69
- let length = (_a = process.stdout) == null ? void 0 : _a.columns;
70
- if (!length || Number.isNaN(length))
71
- length = 30;
72
- return Math.max(length + delta, 0);
73
- }
74
- function divider(text, left, right) {
75
- const cols = getCols();
76
- if (text) {
77
- const textLength = stripAnsi(text).length;
78
- if (left == null && right != null) {
79
- left = cols - textLength - right;
80
- } else {
81
- left = left ?? Math.floor((cols - textLength) / 2);
82
- right = cols - textLength - left;
83
- }
84
- left = Math.max(0, left);
85
- right = Math.max(0, right);
86
- return `${F_LONG_DASH.repeat(left)}${text}${F_LONG_DASH.repeat(right)}`;
87
- }
88
- return F_LONG_DASH.repeat(cols);
89
- }
90
- function formatTestPath(root, path) {
91
- var _a;
92
- if (isAbsolute(path))
93
- path = relative(root, path);
94
- const dir = dirname(path);
95
- const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
96
- const base = basename(path, ext);
97
- return slash(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
98
- }
99
- function renderSnapshotSummary(rootDir, snapshots) {
100
- const summary = [];
101
- if (snapshots.added)
102
- summary.push(c.bold(c.green(`${snapshots.added} written`)));
103
- if (snapshots.unmatched)
104
- summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
105
- if (snapshots.updated)
106
- summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
107
- if (snapshots.filesRemoved) {
108
- if (snapshots.didUpdate)
109
- summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
110
- else
111
- summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
112
- }
113
- if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
114
- const [head, ...tail] = snapshots.filesRemovedList;
115
- summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
116
- tail.forEach((key) => {
117
- summary.push(` ${c.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
118
- });
119
- }
120
- if (snapshots.unchecked) {
121
- if (snapshots.didUpdate)
122
- summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
123
- else
124
- summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
125
- snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
126
- summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
127
- uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
128
- });
129
- }
130
- return summary;
131
- }
132
- function countTestErrors(tasks) {
133
- return tasks.reduce((c2, i) => {
134
- var _a, _b;
135
- return c2 + (((_b = (_a = i.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length) || 0);
136
- }, 0);
137
- }
138
- function getStateString(tasks, name = "tests", showTotal = true) {
139
- if (tasks.length === 0)
140
- return c.dim(`no ${name}`);
141
- const passed = tasks.filter((i) => {
142
- var _a;
143
- return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
144
- });
145
- const failed = tasks.filter((i) => {
146
- var _a;
147
- return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
148
- });
149
- const skipped2 = tasks.filter((i) => i.mode === "skip");
150
- const todo = tasks.filter((i) => i.mode === "todo");
151
- return [
152
- failed.length ? c.bold(c.red(`${failed.length} failed`)) : null,
153
- passed.length ? c.bold(c.green(`${passed.length} passed`)) : null,
154
- skipped2.length ? c.yellow(`${skipped2.length} skipped`) : null,
155
- todo.length ? c.gray(`${todo.length} todo`) : null
156
- ].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
157
- }
158
- function getStateSymbol(task) {
159
- var _a;
160
- if (task.mode === "skip" || task.mode === "todo")
161
- return skipped;
162
- if (!task.result)
163
- return c.gray("\xB7");
164
- if (task.result.state === "run") {
165
- if (task.type === "suite")
166
- return pointer;
167
- let spinner = spinnerMap.get(task);
168
- if (!spinner) {
169
- spinner = elegantSpinner();
170
- spinnerMap.set(task, spinner);
171
- }
172
- return c.yellow(spinner());
173
- }
174
- if (task.result.state === "pass") {
175
- return ((_a = task.meta) == null ? void 0 : _a.benchmark) ? c.green(F_DOT) : c.green(F_CHECK);
176
- }
177
- if (task.result.state === "fail") {
178
- return task.type === "suite" ? pointer : c.red(F_CROSS);
179
- }
180
- return " ";
181
- }
182
- function getHookStateSymbol(task, hookName) {
183
- var _a, _b;
184
- const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
185
- if (state && state === "run") {
186
- let spinnerMap2 = hookSpinnerMap.get(task);
187
- if (!spinnerMap2) {
188
- spinnerMap2 = /* @__PURE__ */ new Map();
189
- hookSpinnerMap.set(task, spinnerMap2);
190
- }
191
- let spinner = spinnerMap2.get(hookName);
192
- if (!spinner) {
193
- spinner = elegantSpinner();
194
- spinnerMap2.set(hookName, spinner);
195
- }
196
- return c.yellow(spinner());
197
- }
198
- }
199
- const spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
200
- function elegantSpinner() {
201
- let index = 0;
202
- return () => {
203
- index = ++index % spinnerFrames.length;
204
- return spinnerFrames[index];
205
- };
206
- }
207
- function formatTimeString(date) {
208
- return date.toTimeString().split(" ")[0];
209
- }
210
- function formatProjectName(name, suffix = " ") {
211
- if (!name)
212
- return "";
213
- const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
214
- const colors = [
215
- c.blue,
216
- c.yellow,
217
- c.cyan,
218
- c.green,
219
- c.magenta
220
- ];
221
- return colors[index % colors.length](`|${name}|`) + suffix;
222
- }
31
+ import { slash } from 'vite-node/utils';
223
32
 
224
33
  const REGEXP_WRAP_PREFIX = "$$vitest:";
225
34
  function getOutputFile(config, reporter) {
@@ -902,7 +711,8 @@ ${PROJECT_FILTER}${FILENAME_PATTERN}${TESTNAME_PATTERN}`);
902
711
  return;
903
712
  const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
904
713
  const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== UNKNOWN_TEST_ID ? log.taskId : "unknown test"}`));
905
- process[log.type].write(`${header}
714
+ const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
715
+ output.write(`${header}
906
716
  ${log.content}
907
717
  `);
908
718
  }
@@ -2300,8 +2110,9 @@ function createDotRenderer(_tasks, options) {
2300
2110
  let tasks = _tasks;
2301
2111
  let timer;
2302
2112
  const { logUpdate: log, outputStream } = options.logger;
2113
+ const columns = "columns" in outputStream ? outputStream.columns : 80;
2303
2114
  function update() {
2304
- log(render(tasks, outputStream.columns));
2115
+ log(render(tasks, columns));
2305
2116
  }
2306
2117
  return {
2307
2118
  start() {
@@ -2320,7 +2131,7 @@ function createDotRenderer(_tasks, options) {
2320
2131
  timer = void 0;
2321
2132
  }
2322
2133
  log.clear();
2323
- options.logger.log(render(tasks, outputStream.columns));
2134
+ options.logger.log(render(tasks, columns));
2324
2135
  return this;
2325
2136
  },
2326
2137
  clear() {
@@ -4328,7 +4139,7 @@ createLogUpdate(process$2.stdout);
4328
4139
 
4329
4140
  createLogUpdate(process$2.stderr);
4330
4141
 
4331
- var version = "1.5.0";
4142
+ var version = "1.5.2";
4332
4143
 
4333
4144
  const HIGHLIGHT_SUPPORTED_EXTS = new Set(["js", "ts"].flatMap((lang) => [
4334
4145
  `.${lang}`,
@@ -4359,7 +4170,7 @@ class BaseSequencer {
4359
4170
  const shardStart = shardSize * (index - 1);
4360
4171
  const shardEnd = shardSize * index;
4361
4172
  return [...files].map((spec) => {
4362
- const fullPath = resolve(slash$1(config.root), slash$1(spec[1]));
4173
+ const fullPath = resolve(slash(config.root), slash(spec[1]));
4363
4174
  const specPath = fullPath == null ? void 0 : fullPath.slice(config.root.length);
4364
4175
  return {
4365
4176
  spec,
@@ -4404,16 +4215,18 @@ const ERASE_SCROLLBACK = `${ESC}3J`;
4404
4215
  const CURSOR_TO_START = `${ESC}1;1H`;
4405
4216
  const CLEAR_SCREEN = "\x1Bc";
4406
4217
  class Logger {
4407
- constructor(ctx, console = globalThis.console) {
4218
+ constructor(ctx, outputStream = process.stdout, errorStream = process.stderr) {
4408
4219
  this.ctx = ctx;
4409
- this.console = console;
4220
+ this.outputStream = outputStream;
4221
+ this.errorStream = errorStream;
4222
+ this.console = new Console({ stdout: outputStream, stderr: errorStream });
4223
+ this.logUpdate = createLogUpdate(this.outputStream);
4410
4224
  this._highlights.clear();
4411
4225
  }
4412
- outputStream = process.stdout;
4413
- errorStream = process.stderr;
4414
- logUpdate = createLogUpdate(process.stdout);
4226
+ logUpdate;
4415
4227
  _clearScreenPending;
4416
4228
  _highlights = /* @__PURE__ */ new Map();
4229
+ console;
4417
4230
  log(...args) {
4418
4231
  this._clearScreen();
4419
4232
  this.console.log(...args);
@@ -4627,7 +4440,7 @@ async function printErrorWrapper(error, ctx, project) {
4627
4440
  });
4628
4441
  const result = await printError(error, project, {
4629
4442
  showCodeFrame: false,
4630
- logger: new Logger(ctx, new Console(writable, writable))
4443
+ logger: new Logger(ctx, writable, writable)
4631
4444
  });
4632
4445
  return { nearest: result == null ? void 0 : result.nearest, output };
4633
4446
  }
@@ -4967,4 +4780,4 @@ const ReportersMap = {
4967
4780
  "github-actions": GithubActionsReporter
4968
4781
  };
4969
4782
 
4970
- export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter$1 as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, BasicReporter as a, DotReporter as b, JUnitReporter as c, TapFlatReporter as d, BenchmarkReportsMap as e, Typechecker as f, RandomSequencer as g, generateCodeFrame as h, highlightCode as i, divider as j, stripAnsi as s, wrapSerializableConfig as w };
4783
+ export { BaseSequencer as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter$1 as J, Logger as L, ReportersMap as R, TapReporter as T, VerboseReporter as V, BasicReporter as a, DotReporter as b, JUnitReporter as c, TapFlatReporter as d, BenchmarkReportsMap as e, Typechecker as f, RandomSequencer as g, generateCodeFrame as h, highlightCode as i, wrapSerializableConfig as w };
@@ -5,7 +5,7 @@ import { distDir } from '../path.js';
5
5
  import { g as getWorkerState } from './global.CkGT_TMy.js';
6
6
  import { r as rpc } from './rpc.joBhAkyK.js';
7
7
  import { t as takeCoverageInsideWorker } from './coverage.E7sG1b3r.js';
8
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.A1De6efh.js';
8
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.7SXMSI--.js';
9
9
 
10
10
  function setupChaiConfig(config) {
11
11
  Object.assign(chai.config, config);
@@ -12,7 +12,7 @@ async function setupCommonEnv(config) {
12
12
  globalSetup = true;
13
13
  setSafeTimers();
14
14
  if (config.globals)
15
- (await import('../chunks/integrations-globals.2J_Aii2q.js')).registerApiGlobally();
15
+ (await import('../chunks/integrations-globals.k0N5-dd1.js')).registerApiGlobally();
16
16
  }
17
17
  function setupDefines(defines) {
18
18
  for (const key in defines)
@@ -21,7 +21,10 @@ function setupDefines(defines) {
21
21
  function setupEnv(env) {
22
22
  if (typeof process === "undefined")
23
23
  return;
24
- for (const key in env)
24
+ const { PROD, DEV, ...restEnvs } = env;
25
+ process.env.PROD = PROD ? "1" : "";
26
+ process.env.DEV = DEV ? "1" : "";
27
+ for (const key in restEnvs)
25
28
  process.env[key] = env[key];
26
29
  }
27
30
  async function loadDiffConfig(config, executor) {
@@ -0,0 +1,217 @@
1
+ import { isAbsolute, relative, dirname, basename } from 'pathe';
2
+ import c from 'picocolors';
3
+ import { a as slash } from './base.Xt0Omgh7.js';
4
+
5
+ const F_RIGHT = "\u2192";
6
+ const F_DOWN = "\u2193";
7
+ const F_DOWN_RIGHT = "\u21B3";
8
+ const F_POINTER = "\u276F";
9
+ const F_DOT = "\xB7";
10
+ const F_CHECK = "\u2713";
11
+ const F_CROSS = "\xD7";
12
+ const F_LONG_DASH = "\u23AF";
13
+
14
+ function ansiRegex({onlyFirst = false} = {}) {
15
+ const pattern = [
16
+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
17
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
18
+ ].join('|');
19
+
20
+ return new RegExp(pattern, onlyFirst ? undefined : 'g');
21
+ }
22
+
23
+ const regex = ansiRegex();
24
+
25
+ function stripAnsi(string) {
26
+ if (typeof string !== 'string') {
27
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
28
+ }
29
+
30
+ // Even though the regex is global, we don't need to reset the `.lastIndex`
31
+ // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
32
+ // and doing it manually has a performance penalty.
33
+ return string.replace(regex, '');
34
+ }
35
+
36
+ const spinnerMap = /* @__PURE__ */ new WeakMap();
37
+ const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
38
+ const pointer = c.yellow(F_POINTER);
39
+ const skipped = c.dim(c.gray(F_DOWN));
40
+ function getCols(delta = 0) {
41
+ var _a;
42
+ let length = (_a = process.stdout) == null ? void 0 : _a.columns;
43
+ if (!length || Number.isNaN(length))
44
+ length = 30;
45
+ return Math.max(length + delta, 0);
46
+ }
47
+ function divider(text, left, right) {
48
+ const cols = getCols();
49
+ if (text) {
50
+ const textLength = stripAnsi(text).length;
51
+ if (left == null && right != null) {
52
+ left = cols - textLength - right;
53
+ } else {
54
+ left = left ?? Math.floor((cols - textLength) / 2);
55
+ right = cols - textLength - left;
56
+ }
57
+ left = Math.max(0, left);
58
+ right = Math.max(0, right);
59
+ return `${F_LONG_DASH.repeat(left)}${text}${F_LONG_DASH.repeat(right)}`;
60
+ }
61
+ return F_LONG_DASH.repeat(cols);
62
+ }
63
+ function formatTestPath(root, path) {
64
+ var _a;
65
+ if (isAbsolute(path))
66
+ path = relative(root, path);
67
+ const dir = dirname(path);
68
+ const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
69
+ const base = basename(path, ext);
70
+ return slash(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
71
+ }
72
+ function renderSnapshotSummary(rootDir, snapshots) {
73
+ const summary = [];
74
+ if (snapshots.added)
75
+ summary.push(c.bold(c.green(`${snapshots.added} written`)));
76
+ if (snapshots.unmatched)
77
+ summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
78
+ if (snapshots.updated)
79
+ summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
80
+ if (snapshots.filesRemoved) {
81
+ if (snapshots.didUpdate)
82
+ summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
83
+ else
84
+ summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
85
+ }
86
+ if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
87
+ const [head, ...tail] = snapshots.filesRemovedList;
88
+ summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
89
+ tail.forEach((key) => {
90
+ summary.push(` ${c.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
91
+ });
92
+ }
93
+ if (snapshots.unchecked) {
94
+ if (snapshots.didUpdate)
95
+ summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
96
+ else
97
+ summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
98
+ snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
99
+ summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
100
+ uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
101
+ });
102
+ }
103
+ return summary;
104
+ }
105
+ function countTestErrors(tasks) {
106
+ return tasks.reduce((c2, i) => {
107
+ var _a, _b;
108
+ return c2 + (((_b = (_a = i.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length) || 0);
109
+ }, 0);
110
+ }
111
+ function getStateString(tasks, name = "tests", showTotal = true) {
112
+ if (tasks.length === 0)
113
+ return c.dim(`no ${name}`);
114
+ const passed = tasks.filter((i) => {
115
+ var _a;
116
+ return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
117
+ });
118
+ const failed = tasks.filter((i) => {
119
+ var _a;
120
+ return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
121
+ });
122
+ const skipped2 = tasks.filter((i) => i.mode === "skip");
123
+ const todo = tasks.filter((i) => i.mode === "todo");
124
+ return [
125
+ failed.length ? c.bold(c.red(`${failed.length} failed`)) : null,
126
+ passed.length ? c.bold(c.green(`${passed.length} passed`)) : null,
127
+ skipped2.length ? c.yellow(`${skipped2.length} skipped`) : null,
128
+ todo.length ? c.gray(`${todo.length} todo`) : null
129
+ ].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
130
+ }
131
+ function getStateSymbol(task) {
132
+ var _a;
133
+ if (task.mode === "skip" || task.mode === "todo")
134
+ return skipped;
135
+ if (!task.result)
136
+ return c.gray("\xB7");
137
+ if (task.result.state === "run") {
138
+ if (task.type === "suite")
139
+ return pointer;
140
+ let spinner = spinnerMap.get(task);
141
+ if (!spinner) {
142
+ spinner = elegantSpinner();
143
+ spinnerMap.set(task, spinner);
144
+ }
145
+ return c.yellow(spinner());
146
+ }
147
+ if (task.result.state === "pass") {
148
+ return ((_a = task.meta) == null ? void 0 : _a.benchmark) ? c.green(F_DOT) : c.green(F_CHECK);
149
+ }
150
+ if (task.result.state === "fail") {
151
+ return task.type === "suite" ? pointer : c.red(F_CROSS);
152
+ }
153
+ return " ";
154
+ }
155
+ function getHookStateSymbol(task, hookName) {
156
+ var _a, _b;
157
+ const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
158
+ if (state && state === "run") {
159
+ let spinnerMap2 = hookSpinnerMap.get(task);
160
+ if (!spinnerMap2) {
161
+ spinnerMap2 = /* @__PURE__ */ new Map();
162
+ hookSpinnerMap.set(task, spinnerMap2);
163
+ }
164
+ let spinner = spinnerMap2.get(hookName);
165
+ if (!spinner) {
166
+ spinner = elegantSpinner();
167
+ spinnerMap2.set(hookName, spinner);
168
+ }
169
+ return c.yellow(spinner());
170
+ }
171
+ }
172
+ const spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
173
+ function elegantSpinner() {
174
+ let index = 0;
175
+ return () => {
176
+ index = ++index % spinnerFrames.length;
177
+ return spinnerFrames[index];
178
+ };
179
+ }
180
+ function formatTimeString(date) {
181
+ return date.toTimeString().split(" ")[0];
182
+ }
183
+ function formatProjectName(name, suffix = " ") {
184
+ if (!name)
185
+ return "";
186
+ const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
187
+ const colors = [
188
+ c.blue,
189
+ c.yellow,
190
+ c.cyan,
191
+ c.green,
192
+ c.magenta
193
+ ];
194
+ return colors[index % colors.length](`|${name}|`) + suffix;
195
+ }
196
+
197
+ var utils = /*#__PURE__*/Object.freeze({
198
+ __proto__: null,
199
+ countTestErrors: countTestErrors,
200
+ divider: divider,
201
+ elegantSpinner: elegantSpinner,
202
+ formatProjectName: formatProjectName,
203
+ formatTestPath: formatTestPath,
204
+ formatTimeString: formatTimeString,
205
+ getCols: getCols,
206
+ getHookStateSymbol: getHookStateSymbol,
207
+ getStateString: getStateString,
208
+ getStateSymbol: getStateSymbol,
209
+ hookSpinnerMap: hookSpinnerMap,
210
+ pointer: pointer,
211
+ renderSnapshotSummary: renderSnapshotSummary,
212
+ skipped: skipped,
213
+ spinnerFrames: spinnerFrames,
214
+ spinnerMap: spinnerMap
215
+ });
216
+
217
+ export { F_RIGHT as F, getStateString as a, formatTimeString as b, countTestErrors as c, divider as d, getCols as e, formatProjectName as f, getStateSymbol as g, getHookStateSymbol as h, F_POINTER as i, pointer as p, renderSnapshotSummary as r, stripAnsi as s, utils as u };
@@ -3337,6 +3337,7 @@ function createVitest() {
3337
3337
  }));
3338
3338
  const _stubsGlobal = /* @__PURE__ */ new Map();
3339
3339
  const _stubsEnv = /* @__PURE__ */ new Map();
3340
+ const _envBooleans = ["PROD", "DEV", "SSR"];
3340
3341
  const getImporter = () => {
3341
3342
  const stackTrace = createSimpleStackTrace({ stackTraceLimit: 4 });
3342
3343
  const importerStack = stackTrace.split("\n")[4];
@@ -3499,7 +3500,10 @@ function createVitest() {
3499
3500
  stubEnv(name, value) {
3500
3501
  if (!_stubsEnv.has(name))
3501
3502
  _stubsEnv.set(name, process.env[name]);
3502
- process.env[name] = value;
3503
+ if (_envBooleans.includes(name))
3504
+ process.env[name] = value ? "1" : "";
3505
+ else
3506
+ process.env[name] = String(value);
3503
3507
  return utils;
3504
3508
  },
3505
3509
  unstubAllGlobals() {
@@ -1,6 +1,6 @@
1
1
  import v8 from 'node:v8';
2
2
  import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.0uYuCbzo.js';
3
- import { r as runBaseTests } from '../vendor/base.BjeeYg4o.js';
3
+ import { r as runBaseTests } from '../vendor/base.gAwDs8Jc.js';
4
4
  import '@vitest/utils';
5
5
  import 'vite-node/client';
6
6
  import '../vendor/global.CkGT_TMy.js';
@@ -6,11 +6,11 @@ import { performance } from 'node:perf_hooks';
6
6
  import { startTests } from '@vitest/runner';
7
7
  import { setupColors, createColors } from '@vitest/utils';
8
8
  import { installSourcemapsSupport } from 'vite-node/source-map';
9
- import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.-ITFwqG_.js';
9
+ import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.gHZzsRJQ.js';
10
10
  import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js';
11
11
  import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
12
- import { V as VitestIndex } from '../vendor/index.12jbrDSD.js';
13
- import { s as setupCommonEnv } from '../vendor/setup-common.A1De6efh.js';
12
+ import { V as VitestIndex } from '../vendor/index.0RrMQKD8.js';
13
+ import { s as setupCommonEnv } from '../vendor/setup-common.7SXMSI--.js';
14
14
  import { c as closeInspector } from '../vendor/inspector.IgLX3ur5.js';
15
15
  import 'chai';
16
16
  import '@vitest/snapshot/environment';
@@ -24,7 +24,7 @@ import '@vitest/runner/utils';
24
24
  import '../vendor/index.ir9i0ywP.js';
25
25
  import 'std-env';
26
26
  import '../vendor/run-once.Olz_Zkd8.js';
27
- import '../vendor/vi.Fxjax7rQ.js';
27
+ import '../vendor/vi.Y_w82WR8.js';
28
28
  import '../vendor/_commonjsHelpers.jjO7Zipk.js';
29
29
  import '@vitest/expect';
30
30
  import '@vitest/snapshot';
@@ -1,4 +1,4 @@
1
- import { r as runBaseTests } from '../vendor/base.BjeeYg4o.js';
1
+ import { r as runBaseTests } from '../vendor/base.gAwDs8Jc.js';
2
2
  import { a as createThreadsRpcOptions } from '../vendor/utils.0uYuCbzo.js';
3
3
  import 'vite-node/client';
4
4
  import '../vendor/global.CkGT_TMy.js';
package/dist/workers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as v8 from 'v8';
2
- import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-LqC_WI4d.js';
2
+ import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-xEmem8D4.js';
3
3
  import { Awaitable } from '@vitest/utils';
4
4
  import 'vite';
5
5
  import '@vitest/runner';
@@ -8,6 +8,7 @@ import '@vitest/snapshot';
8
8
  import '@vitest/expect';
9
9
  import '@vitest/runner/utils';
10
10
  import 'tinybench';
11
+ import 'node:stream';
11
12
  import 'vite-node/client';
12
13
  import '@vitest/snapshot/manager';
13
14
  import 'vite-node/server';
package/dist/workers.js CHANGED
@@ -2,7 +2,7 @@ export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSe
2
2
  export { p as provideWorkerState } from './vendor/global.CkGT_TMy.js';
3
3
  export { run as runVitestWorker } from './worker.js';
4
4
  export { r as runVmTests } from './vendor/vm.I_IsyNig.js';
5
- export { r as runBaseTests } from './vendor/base.BjeeYg4o.js';
5
+ export { r as runBaseTests } from './vendor/base.gAwDs8Jc.js';
6
6
  import '@vitest/utils';
7
7
  import 'node:url';
8
8
  import 'tinypool';