vitest 0.29.8 → 0.30.0

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 (56) hide show
  1. package/LICENSE.md +2 -81
  2. package/dist/browser.d.ts +5 -3
  3. package/dist/browser.js +5 -6
  4. package/dist/child.js +12 -16
  5. package/dist/{chunk-api-setup.3aabe9ac.js → chunk-api-setup.6662587e.js} +53 -48
  6. package/dist/{chunk-install-pkg.6aa7cf6d.js → chunk-install-pkg.6450b372.js} +32 -32
  7. package/dist/chunk-integrations-globals.d419838f.js +26 -0
  8. package/dist/{chunk-node-git.ed5bded8.js → chunk-node-git.4c43bd73.js} +4 -2
  9. package/dist/cli-wrapper.js +6 -5
  10. package/dist/cli.js +26 -26
  11. package/dist/config.cjs +15 -2
  12. package/dist/config.d.ts +15 -4
  13. package/dist/config.js +10 -1
  14. package/dist/coverage.d.ts +5 -2
  15. package/dist/coverage.js +6 -0
  16. package/dist/entry.js +34 -34
  17. package/dist/environments.d.ts +5 -2
  18. package/dist/environments.js +1 -1
  19. package/dist/index.d.ts +11 -10
  20. package/dist/index.js +9 -11
  21. package/dist/loader.js +396 -13
  22. package/dist/node.d.ts +9 -7
  23. package/dist/node.js +27 -30
  24. package/dist/runners.d.ts +5 -2
  25. package/dist/runners.js +34 -31
  26. package/dist/{types-94cfe4b4.d.ts → types-f03c83c4.d.ts} +225 -306
  27. package/dist/{chunk-node-pkg.30d8b37e.js → vendor-cli-api.c04eaa34.js} +3845 -3326
  28. package/dist/vendor-constants.538d9b49.js +54 -0
  29. package/dist/{chunk-runtime-mocker.3283818a.js → vendor-execute.8eaab47b.js} +9 -12
  30. package/dist/{chunk-utils-base.b5ddfcc9.js → vendor-index.4f82d248.js} +80 -10
  31. package/dist/{chunk-env-node.affdd278.js → vendor-index.75f2b63d.js} +9 -2
  32. package/dist/{chunk-integrations-utils.23c19408.js → vendor-index.81b9e499.js} +22 -21
  33. package/dist/{vendor-index.2cbcdd1e.js → vendor-index.c1e09929.js} +458 -373
  34. package/dist/vendor-index.fad2598b.js +44 -0
  35. package/dist/{vendor-index.534e612c.js → vendor-index.fc98d30f.js} +2 -2
  36. package/dist/{chunk-runtime-inspector.b1427a10.js → vendor-inspector.47fc8cbb.js} +5 -2
  37. package/dist/{chunk-runtime-rpc.d6aa57f8.js → vendor-rpc.4d3d7a54.js} +5 -5
  38. package/dist/{chunk-integrations-run-once.ea614f17.js → vendor-run-once.69ce7172.js} +3 -3
  39. package/dist/{chunk-runtime-setup.5d504677.js → vendor-setup.common.cef38f4e.js} +2 -2
  40. package/dist/vendor-tasks.042d6084.js +14 -0
  41. package/dist/{chunk-utils-import.e488ace3.js → vendor-vi.a3ff54b1.js} +73 -2957
  42. package/dist/worker.js +13 -18
  43. package/package.json +29 -34
  44. package/dist/chunk-constants.bc18a549.js +0 -36
  45. package/dist/chunk-integrations-globals.49802775.js +0 -28
  46. package/dist/chunk-snapshot-env.a347d647.js +0 -11
  47. package/dist/chunk-utils-env.6b856dbf.js +0 -64
  48. package/dist/chunk-utils-tasks.8781fd71.js +0 -107
  49. package/dist/env-afee91f0.d.ts +0 -10
  50. package/dist/vendor-index.783e7f3e.js +0 -71
  51. package/dist/vendor-index.bdee400f.js +0 -396
  52. package/dist/vendor-magic-string.es.b3bc5745.js +0 -1591
  53. /package/dist/{vendor-_commonjsHelpers.addc3445.js → vendor-_commonjsHelpers.76cdd49e.js} +0 -0
  54. /package/dist/{chunk-integrations-coverage.d93ee824.js → vendor-coverage.a585b712.js} +0 -0
  55. /package/dist/{chunk-utils-global.fd174983.js → vendor-global.6795f91f.js} +0 -0
  56. /package/dist/{chunk-paths.e36446b4.js → vendor-paths.84fc7a99.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,26 +1,29 @@
1
- import { Test } from '@vitest/runner';
2
1
  export { SequenceHooks, SequenceSetupFiles, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
3
- import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, S as SnapshotResult, c as Reporter } from './types-94cfe4b4.js';
4
- export { A as AfterSuiteRunMeta, k as ApiConfig, H as ArgumentsType, G as Arrayable, D as Awaitable, a2 as BaseCoverageOptions, a9 as BenchFunction, a7 as Benchmark, B as BenchmarkAPI, a8 as BenchmarkResult, a6 as BenchmarkUserOptions, h as BuiltinEnvironment, j as CSSModuleScopeStrategy, C as CollectLineNumbers, e as CollectLines, L as Constructable, g as Context, q as ContextRPC, p as ContextTestEnvironment, a4 as CoverageC8Options, a3 as CoverageIstanbulOptions, a0 as CoverageOptions, Y as CoverageProvider, _ as CoverageProviderModule, $ as CoverageReporter, a5 as CustomProviderOptions, Q as Environment, E as EnvironmentOptions, P as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, O as ModuleCache, b as ModuleGraphData, K as MutableArray, N as Nullable, X as OnServerRestartHandler, d as RawErrsMap, Z as ReportContext, c as Reporter, y as ResolveIdFunction, a as ResolvedConfig, a1 as ResolvedCoverageOptions, f as RootAndTarget, R as RuntimeConfig, o as RuntimeRPC, s as SnapshotData, v as SnapshotMatchOptions, S as SnapshotResult, u as SnapshotStateOptions, x as SnapshotSummary, t as SnapshotUpdateState, T as TscErrorInfo, m as TypecheckConfig, w as UncheckedSnapshot, n as UserConfig, U as UserConsoleLog, r as Vitest, V as VitestEnvironment, i as VitestPool, l as VitestRunMode, W as WorkerContext, z as WorkerGlobalState } from './types-94cfe4b4.js';
2
+ import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-f03c83c4.js';
3
+ export { n as ApiConfig, D as ArgumentsType, z as Arrayable, y as Awaitable, a0 as BaseCoverageOptions, a7 as BenchFunction, a5 as Benchmark, a6 as BenchmarkResult, a4 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, H as Constructable, j as Context, u as ContextRPC, t as ContextTestEnvironment, a2 as CoverageC8Options, a1 as CoverageIstanbulOptions, _ as CoverageOptions, S as CoverageProvider, Y as CoverageProviderModule, Z as CoverageReporter, a3 as CustomProviderOptions, O as Environment, E as EnvironmentOptions, L as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, K as ModuleCache, G as MutableArray, N as Nullable, Q as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, X as ReportContext, w as ResolveIdFunction, $ as ResolvedCoverageOptions, i as RootAndTarget, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, v as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, x as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-f03c83c4.js';
5
4
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy';
6
5
  export { EnhancedSpy, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
7
- export { S as SnapshotEnvironment } from './env-afee91f0.js';
6
+ export { SnapshotEnvironment } from '@vitest/snapshot/environment';
8
7
  import { File, TaskResultPack } from '@vitest/runner/types';
9
8
  export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions } from '@vitest/runner/types';
9
+ import { SnapshotResult } from '@vitest/snapshot';
10
+ export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
10
11
  import { TransformResult } from 'vite';
11
12
  import * as chai from 'chai';
12
13
  export { chai };
13
14
  export { assert, should } from 'chai';
15
+ export { UserWorkspaceConfig } from './config.js';
14
16
  export { ErrorWithDiff, ParsedStack } from '@vitest/runner/utils';
15
17
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
16
18
  import '@vitest/expect';
17
19
  import '@vitest/utils';
18
20
  import 'vite-node/client';
21
+ import '@vitest/snapshot/manager';
19
22
  import 'node:worker_threads';
20
23
  import 'vite-node';
21
24
  import 'source-map';
22
- import 'node:fs';
23
25
  import 'vite-node/server';
26
+ import 'node:fs';
24
27
 
25
28
  declare type Not<T extends boolean> = T extends true ? false : true;
26
29
  declare type And<Types extends boolean[]> = Types[number] extends true ? true : false;
@@ -181,9 +184,6 @@ declare function runOnce<T>(fn: (() => T), key?: string): T;
181
184
  */
182
185
  declare function isFirstRun(): boolean;
183
186
 
184
- declare function createExpect(test?: Test): Vi.ExpectStatic;
185
- declare const globalExpect: Vi.ExpectStatic;
186
-
187
187
  interface VitestUtils {
188
188
  useFakeTimers(config?: FakeTimerInstallOpts): this;
189
189
  useRealTimers(): this;
@@ -323,7 +323,7 @@ interface VitestUtils {
323
323
  declare const vitest: VitestUtils;
324
324
  declare const vi: VitestUtils;
325
325
 
326
- declare function getRunningMode(): "run" | "watch";
326
+ declare function getRunningMode(): "watch" | "run";
327
327
  declare function isWatchMode(): boolean;
328
328
 
329
329
  interface TransformResultWithSource extends TransformResult {
@@ -339,6 +339,7 @@ interface WebSocketHandlers {
339
339
  getPaths(): string[];
340
340
  getConfig(): ResolvedConfig;
341
341
  resolveSnapshotPath(testPath: string): string;
342
+ resolveSnapshotRawPath(testPath: string, rawPath: string): string;
342
343
  getModuleGraph(id: string): Promise<ModuleGraphData>;
343
344
  getTransformResult(id: string): Promise<TransformResultWithSource | undefined>;
344
345
  readFile(id: string): Promise<string | null>;
@@ -352,4 +353,4 @@ interface WebSocketHandlers {
352
353
  interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
353
354
  }
354
355
 
355
- export { AssertType, ExpectTypeOf, TransformResultWithSource, WebSocketEvents, WebSocketHandlers, assertType, bench, createExpect, globalExpect as expect, expectTypeOf, getRunningMode, isFirstRun, isWatchMode, runOnce, vi, vitest };
356
+ export { AfterSuiteRunMeta, AssertType, BenchmarkAPI, ExpectTypeOf, ModuleGraphData, Reporter, ResolvedConfig, RuntimeConfig, TransformResultWithSource, UserConsoleLog, WebSocketEvents, WebSocketHandlers, assertType, bench, expectTypeOf, getRunningMode, isFirstRun, isWatchMode, runOnce, vi, vitest };
package/dist/index.js CHANGED
@@ -1,23 +1,21 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- export { b as bench, c as createExpect, g as expect, a as vi, v as vitest } from './chunk-utils-import.e488ace3.js';
3
- export { i as isFirstRun, r as runOnce } from './chunk-integrations-run-once.ea614f17.js';
4
- import { d as dist } from './chunk-integrations-utils.23c19408.js';
5
- export { b as assertType, g as getRunningMode, a as isWatchMode } from './chunk-integrations-utils.23c19408.js';
2
+ export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.a3ff54b1.js';
3
+ export { i as isFirstRun, a as runOnce } from './vendor-run-once.69ce7172.js';
4
+ import { d as dist } from './vendor-index.81b9e499.js';
5
+ export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.81b9e499.js';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
8
8
  export { assert, should } from 'chai';
9
9
  import '@vitest/runner/utils';
10
10
  import '@vitest/utils';
11
- import './chunk-utils-env.6b856dbf.js';
11
+ import './vendor-index.fad2598b.js';
12
12
  import 'pathe';
13
13
  import 'std-env';
14
- import './chunk-utils-global.fd174983.js';
15
- import './vendor-_commonjsHelpers.addc3445.js';
14
+ import './vendor-global.6795f91f.js';
15
+ import './vendor-_commonjsHelpers.76cdd49e.js';
16
16
  import '@vitest/expect';
17
- import './chunk-runtime-rpc.d6aa57f8.js';
18
- import './chunk-snapshot-env.a347d647.js';
19
- import './chunk-utils-base.b5ddfcc9.js';
20
- import './chunk-utils-tasks.8781fd71.js';
17
+ import '@vitest/snapshot';
18
+ import './vendor-tasks.042d6084.js';
21
19
  import 'util';
22
20
  import '@vitest/spy';
23
21
 
package/dist/loader.js CHANGED
@@ -1,22 +1,405 @@
1
1
  import { pathToFileURL, fileURLToPath } from 'node:url';
2
2
  import { readFile } from 'node:fs/promises';
3
- import { i as isNodeBuiltin, h as hasCJSSyntax } from './vendor-index.bdee400f.js';
4
- import { normalizeModuleId } from 'vite-node/utils';
5
- import './chunk-utils-env.6b856dbf.js';
6
- import { g as getWorkerState } from './chunk-utils-global.fd174983.js';
7
3
  import 'acorn';
8
- import 'node:module';
4
+ import { builtinModules } from 'node:module';
9
5
  import 'node:fs';
10
6
  import 'pathe';
11
- import 'node:assert';
12
- import 'node:process';
7
+ import assert from 'node:assert';
8
+ import process$1 from 'node:process';
13
9
  import 'node:path';
14
- import 'node:v8';
15
- import 'node:util';
10
+ import v8 from 'node:v8';
11
+ import { format, inspect } from 'node:util';
12
+ import { normalizeModuleId } from 'vite-node/utils';
13
+ import './vendor-index.fad2598b.js';
14
+ import { g as getWorkerState } from './vendor-global.6795f91f.js';
16
15
  import 'std-env';
17
16
  import '@vitest/runner/utils';
18
17
  import '@vitest/utils';
19
18
 
19
+ const BUILTIN_MODULES = new Set(builtinModules);
20
+
21
+ /**
22
+ * @typedef ErrnoExceptionFields
23
+ * @property {number | undefined} [errnode]
24
+ * @property {string | undefined} [code]
25
+ * @property {string | undefined} [path]
26
+ * @property {string | undefined} [syscall]
27
+ * @property {string | undefined} [url]
28
+ *
29
+ * @typedef {Error & ErrnoExceptionFields} ErrnoException
30
+ */
31
+
32
+ const isWindows = process$1.platform === 'win32';
33
+
34
+ const own$1 = {}.hasOwnProperty;
35
+
36
+ /**
37
+ * Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
38
+ * We cannot use Intl.ListFormat because it's not available in
39
+ * --without-intl builds.
40
+ *
41
+ * @param {Array<string>} array
42
+ * An array of strings.
43
+ * @param {string} [type]
44
+ * The list type to be inserted before the last element.
45
+ * @returns {string}
46
+ */
47
+ function formatList(array, type = 'and') {
48
+ return array.length < 3
49
+ ? array.join(` ${type} `)
50
+ : `${array.slice(0, -1).join(', ')}, ${type} ${array[array.length - 1]}`
51
+ }
52
+
53
+ /** @type {Map<string, MessageFunction|string>} */
54
+ const messages = new Map();
55
+ const nodeInternalPrefix = '__node_internal_';
56
+ /** @type {number} */
57
+ let userStackTraceLimit;
58
+
59
+ createError(
60
+ 'ERR_INVALID_MODULE_SPECIFIER',
61
+ /**
62
+ * @param {string} request
63
+ * @param {string} reason
64
+ * @param {string} [base]
65
+ */
66
+ (request, reason, base = undefined) => {
67
+ return `Invalid module "${request}" ${reason}${
68
+ base ? ` imported from ${base}` : ''
69
+ }`
70
+ },
71
+ TypeError
72
+ );
73
+
74
+ createError(
75
+ 'ERR_INVALID_PACKAGE_CONFIG',
76
+ /**
77
+ * @param {string} path
78
+ * @param {string} [base]
79
+ * @param {string} [message]
80
+ */
81
+ (path, base, message) => {
82
+ return `Invalid package config ${path}${
83
+ base ? ` while importing ${base}` : ''
84
+ }${message ? `. ${message}` : ''}`
85
+ },
86
+ Error
87
+ );
88
+
89
+ createError(
90
+ 'ERR_INVALID_PACKAGE_TARGET',
91
+ /**
92
+ * @param {string} pkgPath
93
+ * @param {string} key
94
+ * @param {unknown} target
95
+ * @param {boolean} [isImport=false]
96
+ * @param {string} [base]
97
+ */
98
+ (pkgPath, key, target, isImport = false, base = undefined) => {
99
+ const relError =
100
+ typeof target === 'string' &&
101
+ !isImport &&
102
+ target.length > 0 &&
103
+ !target.startsWith('./');
104
+ if (key === '.') {
105
+ assert(isImport === false);
106
+ return (
107
+ `Invalid "exports" main target ${JSON.stringify(target)} defined ` +
108
+ `in the package config ${pkgPath}package.json${
109
+ base ? ` imported from ${base}` : ''
110
+ }${relError ? '; targets must start with "./"' : ''}`
111
+ )
112
+ }
113
+
114
+ return `Invalid "${
115
+ isImport ? 'imports' : 'exports'
116
+ }" target ${JSON.stringify(
117
+ target
118
+ )} defined for '${key}' in the package config ${pkgPath}package.json${
119
+ base ? ` imported from ${base}` : ''
120
+ }${relError ? '; targets must start with "./"' : ''}`
121
+ },
122
+ Error
123
+ );
124
+
125
+ createError(
126
+ 'ERR_MODULE_NOT_FOUND',
127
+ /**
128
+ * @param {string} path
129
+ * @param {string} base
130
+ * @param {string} [type]
131
+ */
132
+ (path, base, type = 'package') => {
133
+ return `Cannot find ${type} '${path}' imported from ${base}`
134
+ },
135
+ Error
136
+ );
137
+
138
+ createError(
139
+ 'ERR_NETWORK_IMPORT_DISALLOWED',
140
+ "import of '%s' by %s is not supported: %s",
141
+ Error
142
+ );
143
+
144
+ createError(
145
+ 'ERR_PACKAGE_IMPORT_NOT_DEFINED',
146
+ /**
147
+ * @param {string} specifier
148
+ * @param {string} packagePath
149
+ * @param {string} base
150
+ */
151
+ (specifier, packagePath, base) => {
152
+ return `Package import specifier "${specifier}" is not defined${
153
+ packagePath ? ` in package ${packagePath}package.json` : ''
154
+ } imported from ${base}`
155
+ },
156
+ TypeError
157
+ );
158
+
159
+ createError(
160
+ 'ERR_PACKAGE_PATH_NOT_EXPORTED',
161
+ /**
162
+ * @param {string} pkgPath
163
+ * @param {string} subpath
164
+ * @param {string} [base]
165
+ */
166
+ (pkgPath, subpath, base = undefined) => {
167
+ if (subpath === '.')
168
+ return `No "exports" main defined in ${pkgPath}package.json${
169
+ base ? ` imported from ${base}` : ''
170
+ }`
171
+ return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${
172
+ base ? ` imported from ${base}` : ''
173
+ }`
174
+ },
175
+ Error
176
+ );
177
+
178
+ createError(
179
+ 'ERR_UNSUPPORTED_DIR_IMPORT',
180
+ "Directory import '%s' is not supported " +
181
+ 'resolving ES modules imported from %s',
182
+ Error
183
+ );
184
+
185
+ createError(
186
+ 'ERR_UNKNOWN_FILE_EXTENSION',
187
+ /**
188
+ * @param {string} ext
189
+ * @param {string} path
190
+ */
191
+ (ext, path) => {
192
+ return `Unknown file extension "${ext}" for ${path}`
193
+ },
194
+ TypeError
195
+ );
196
+
197
+ createError(
198
+ 'ERR_INVALID_ARG_VALUE',
199
+ /**
200
+ * @param {string} name
201
+ * @param {unknown} value
202
+ * @param {string} [reason='is invalid']
203
+ */
204
+ (name, value, reason = 'is invalid') => {
205
+ let inspected = inspect(value);
206
+
207
+ if (inspected.length > 128) {
208
+ inspected = `${inspected.slice(0, 128)}...`;
209
+ }
210
+
211
+ const type = name.includes('.') ? 'property' : 'argument';
212
+
213
+ return `The ${type} '${name}' ${reason}. Received ${inspected}`
214
+ },
215
+ TypeError
216
+ // Note: extra classes have been shaken out.
217
+ // , RangeError
218
+ );
219
+
220
+ createError(
221
+ 'ERR_UNSUPPORTED_ESM_URL_SCHEME',
222
+ /**
223
+ * @param {URL} url
224
+ * @param {Array<string>} supported
225
+ */
226
+ (url, supported) => {
227
+ let message = `Only URLs with a scheme in: ${formatList(
228
+ supported
229
+ )} are supported by the default ESM loader`;
230
+
231
+ if (isWindows && url.protocol.length === 2) {
232
+ message += '. On Windows, absolute paths must be valid file:// URLs';
233
+ }
234
+
235
+ message += `. Received protocol '${url.protocol}'`;
236
+ return message
237
+ },
238
+ Error
239
+ );
240
+
241
+ /**
242
+ * Utility function for registering the error codes. Only used here. Exported
243
+ * *only* to allow for testing.
244
+ * @param {string} sym
245
+ * @param {MessageFunction|string} value
246
+ * @param {ErrorConstructor} def
247
+ * @returns {new (...args: Array<any>) => Error}
248
+ */
249
+ function createError(sym, value, def) {
250
+ // Special case for SystemError that formats the error message differently
251
+ // The SystemErrors only have SystemError as their base classes.
252
+ messages.set(sym, value);
253
+
254
+ return makeNodeErrorWithCode(def, sym)
255
+ }
256
+
257
+ /**
258
+ * @param {ErrorConstructor} Base
259
+ * @param {string} key
260
+ * @returns {ErrorConstructor}
261
+ */
262
+ function makeNodeErrorWithCode(Base, key) {
263
+ // @ts-expect-error It’s a Node error.
264
+ return NodeError
265
+ /**
266
+ * @param {Array<unknown>} args
267
+ */
268
+ function NodeError(...args) {
269
+ const limit = Error.stackTraceLimit;
270
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
271
+ const error = new Base();
272
+ // Reset the limit and setting the name property.
273
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
274
+ const message = getMessage(key, args, error);
275
+ Object.defineProperties(error, {
276
+ // Note: no need to implement `kIsNodeError` symbol, would be hard,
277
+ // probably.
278
+ message: {
279
+ value: message,
280
+ enumerable: false,
281
+ writable: true,
282
+ configurable: true
283
+ },
284
+ toString: {
285
+ /** @this {Error} */
286
+ value() {
287
+ return `${this.name} [${key}]: ${this.message}`
288
+ },
289
+ enumerable: false,
290
+ writable: true,
291
+ configurable: true
292
+ }
293
+ });
294
+
295
+ captureLargerStackTrace(error);
296
+ // @ts-expect-error It’s a Node error.
297
+ error.code = key;
298
+ return error
299
+ }
300
+ }
301
+
302
+ /**
303
+ * @returns {boolean}
304
+ */
305
+ function isErrorStackTraceLimitWritable() {
306
+ // Do no touch Error.stackTraceLimit as V8 would attempt to install
307
+ // it again during deserialization.
308
+ try {
309
+ // @ts-expect-error: not in types?
310
+ if (v8.startupSnapshot.isBuildingSnapshot()) {
311
+ return false
312
+ }
313
+ } catch {}
314
+
315
+ const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit');
316
+ if (desc === undefined) {
317
+ return Object.isExtensible(Error)
318
+ }
319
+
320
+ return own$1.call(desc, 'writable') && desc.writable !== undefined
321
+ ? desc.writable
322
+ : desc.set !== undefined
323
+ }
324
+
325
+ /**
326
+ * This function removes unnecessary frames from Node.js core errors.
327
+ * @template {(...args: unknown[]) => unknown} T
328
+ * @param {T} fn
329
+ * @returns {T}
330
+ */
331
+ function hideStackFrames(fn) {
332
+ // We rename the functions that will be hidden to cut off the stacktrace
333
+ // at the outermost one
334
+ const hidden = nodeInternalPrefix + fn.name;
335
+ Object.defineProperty(fn, 'name', {value: hidden});
336
+ return fn
337
+ }
338
+
339
+ const captureLargerStackTrace = hideStackFrames(
340
+ /**
341
+ * @param {Error} error
342
+ * @returns {Error}
343
+ */
344
+ // @ts-expect-error: fine
345
+ function (error) {
346
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
347
+ if (stackTraceLimitIsWritable) {
348
+ userStackTraceLimit = Error.stackTraceLimit;
349
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
350
+ }
351
+
352
+ Error.captureStackTrace(error);
353
+
354
+ // Reset the limit
355
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
356
+
357
+ return error
358
+ }
359
+ );
360
+
361
+ /**
362
+ * @param {string} key
363
+ * @param {Array<unknown>} args
364
+ * @param {Error} self
365
+ * @returns {string}
366
+ */
367
+ function getMessage(key, args, self) {
368
+ const message = messages.get(key);
369
+ assert(typeof message !== 'undefined', 'expected `message` to be found');
370
+
371
+ if (typeof message === 'function') {
372
+ assert(
373
+ message.length <= args.length, // Default options do not count.
374
+ `Code: ${key}; The provided arguments length (${args.length}) does not ` +
375
+ `match the required ones (${message.length}).`
376
+ );
377
+ return Reflect.apply(message, self, args)
378
+ }
379
+
380
+ const regex = /%[dfijoOs]/g;
381
+ let expectedLength = 0;
382
+ while (regex.exec(message) !== null) expectedLength++;
383
+ assert(
384
+ expectedLength === args.length,
385
+ `Code: ${key}; The provided arguments length (${args.length}) does not ` +
386
+ `match the required ones (${expectedLength}).`
387
+ );
388
+ if (args.length === 0) return message
389
+
390
+ args.unshift(message);
391
+ return Reflect.apply(format, null, args)
392
+ }
393
+ function isNodeBuiltin(id = "") {
394
+ id = id.replace(/^node:/, "").split("/")[0];
395
+ return BUILTIN_MODULES.has(id);
396
+ }
397
+ pathToFileURL(process.cwd());
398
+ const CJS_RE = /([\s;]|^)(module.exports\b|exports\.\w|require\s*\(|global\.\w)/m;
399
+ function hasCJSSyntax(code) {
400
+ return CJS_RE.test(code);
401
+ }
402
+
20
403
  var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
21
404
  ModuleFormat2["Builtin"] = "builtin";
22
405
  ModuleFormat2["Commonjs"] = "commonjs";
@@ -31,7 +414,7 @@ function hasESMSyntax(code) {
31
414
  return ESM_RE.test(code);
32
415
  }
33
416
  const cache = /* @__PURE__ */ new Map();
34
- const getPotentialSource = async (filepath, result) => {
417
+ async function getPotentialSource(filepath, result) {
35
418
  var _a;
36
419
  if (!result.url.startsWith("file://") || result.format === "module")
37
420
  return null;
@@ -39,15 +422,15 @@ const getPotentialSource = async (filepath, result) => {
39
422
  if (source == null)
40
423
  source = await readFile(filepath, "utf8");
41
424
  return source;
42
- };
43
- const detectESM = (url, source) => {
425
+ }
426
+ function detectESM(url, source) {
44
427
  const cached = cache.get(url);
45
428
  if (cached)
46
429
  return cached.isPseudoESM;
47
430
  if (!source)
48
431
  return false;
49
432
  return hasESMSyntax(source) && !hasCJSSyntax(source);
50
- };
433
+ }
51
434
  const resolve = async (url, context, next) => {
52
435
  const { parentURL } = context;
53
436
  const state = getWorkerState();
package/dist/node.d.ts CHANGED
@@ -1,18 +1,21 @@
1
- import { l as VitestRunMode, n as UserConfig, r as Vitest, aa as MockFactory, ab as MockMap, ac as TestSequencer } from './types-94cfe4b4.js';
2
- export { ac as TestSequencer, ae as TestSequencerConstructor, r as Vitest, ad as startVitest } from './types-94cfe4b4.js';
1
+ import { o as VitestRunMode, q as UserConfig, v as Vitest, a8 as MockFactory, a9 as MockMap, aa as TestSequencer, ab as WorkspaceSpec } from './types-f03c83c4.js';
2
+ export { ae as TestSequencerConstructor, ac as VitestWorkspace, ad as startVitest } from './types-f03c83c4.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import { ViteNodeRunner } from 'vite-node/client';
5
5
  import { ViteNodeRunnerOptions } from 'vite-node';
6
6
  import '@vitest/expect';
7
+ import '@vitest/snapshot';
7
8
  import '@vitest/runner';
8
9
  import '@vitest/runner/types';
9
10
  import '@vitest/runner/utils';
10
11
  import '@vitest/utils';
11
12
  import 'tinybench';
13
+ import '@vitest/snapshot/manager';
12
14
  import 'node:worker_threads';
13
15
  import 'source-map';
14
- import 'node:fs';
15
16
  import 'vite-node/server';
17
+ import 'node:fs';
18
+ import 'chai';
16
19
 
17
20
  declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
18
21
 
@@ -25,7 +28,6 @@ declare class VitestMocker {
25
28
  private resolveCache;
26
29
  constructor(executor: VitestExecutor);
27
30
  private get root();
28
- private get base();
29
31
  private get mockMap();
30
32
  private get moduleCache();
31
33
  private deleteCachedItem;
@@ -66,8 +68,8 @@ declare class VitestExecutor extends ViteNodeRunner {
66
68
  declare class BaseSequencer implements TestSequencer {
67
69
  protected ctx: Vitest;
68
70
  constructor(ctx: Vitest);
69
- shard(files: string[]): Promise<string[]>;
70
- sort(files: string[]): Promise<string[]>;
71
+ shard(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
72
+ sort(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
71
73
  }
72
74
 
73
- export { BaseSequencer, ExecuteOptions, VitestExecutor, VitestPlugin, createVitest };
75
+ export { BaseSequencer, ExecuteOptions, TestSequencer, Vitest, VitestExecutor, VitestPlugin, WorkspaceSpec, createVitest };
package/dist/node.js CHANGED
@@ -1,17 +1,17 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-node-pkg.30d8b37e.js';
2
- export { V as VitestExecutor } from './chunk-runtime-mocker.3283818a.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.c04eaa34.js';
2
+ export { V as VitestExecutor } from './vendor-execute.8eaab47b.js';
3
3
  import 'pathe';
4
- import './chunk-constants.bc18a549.js';
5
- import './chunk-integrations-coverage.d93ee824.js';
6
- import './chunk-env-node.affdd278.js';
4
+ import './vendor-constants.538d9b49.js';
5
+ import './vendor-coverage.a585b712.js';
6
+ import './vendor-index.75f2b63d.js';
7
7
  import 'node:console';
8
8
  import 'local-pkg';
9
9
  import 'picocolors';
10
- import './chunk-utils-env.6b856dbf.js';
10
+ import './vendor-index.fad2598b.js';
11
11
  import 'std-env';
12
12
  import '@vitest/runner/utils';
13
- import './chunk-utils-global.fd174983.js';
14
13
  import '@vitest/utils';
14
+ import './vendor-global.6795f91f.js';
15
15
  import 'vite';
16
16
  import 'node:path';
17
17
  import 'node:url';
@@ -23,39 +23,36 @@ import 'util';
23
23
  import 'stream';
24
24
  import 'events';
25
25
  import 'fs';
26
- import './vendor-_commonjsHelpers.addc3445.js';
26
+ import './vendor-_commonjsHelpers.76cdd49e.js';
27
27
  import 'vite-node/utils';
28
28
  import 'vite-node/client';
29
- import 'node:fs/promises';
30
- import './vendor-index.2cbcdd1e.js';
31
- import 'node:buffer';
29
+ import '@vitest/snapshot/manager';
30
+ import './vendor-paths.84fc7a99.js';
31
+ import 'node:v8';
32
32
  import 'node:child_process';
33
- import 'child_process';
33
+ import './vendor-index.4f82d248.js';
34
+ import 'node:worker_threads';
34
35
  import 'node:os';
36
+ import 'tinypool';
37
+ import 'node:perf_hooks';
38
+ import './vendor-tasks.042d6084.js';
39
+ import 'node:module';
40
+ import 'node:crypto';
41
+ import './vendor-index.c1e09929.js';
42
+ import 'node:buffer';
43
+ import 'child_process';
35
44
  import 'assert';
36
45
  import 'buffer';
46
+ import 'node:util';
47
+ import 'node:fs/promises';
37
48
  import 'source-map';
38
49
  import 'module';
39
50
  import 'acorn';
40
51
  import 'acorn-walk';
41
- import './chunk-utils-base.b5ddfcc9.js';
42
- import 'crypto';
43
- import './chunk-paths.e36446b4.js';
44
- import 'node:v8';
45
- import './vendor-index.783e7f3e.js';
46
- import 'node:worker_threads';
47
- import 'tinypool';
48
- import 'perf_hooks';
49
- import './chunk-utils-tasks.8781fd71.js';
50
- import '@vitest/utils/diff';
51
- import 'vite-node/server';
52
- import './vendor-magic-string.es.b3bc5745.js';
53
- import 'node:module';
54
- import 'node:crypto';
52
+ import 'magic-string';
55
53
  import 'strip-literal';
54
+ import 'vite-node/server';
55
+ import 'node:readline';
56
56
  import 'readline';
57
- import './vendor-index.bdee400f.js';
58
- import 'node:assert';
59
- import 'node:util';
60
57
  import '@vitest/spy';
61
- import './chunk-runtime-rpc.d6aa57f8.js';
58
+ import './vendor-rpc.4d3d7a54.js';