vitest 0.29.7 → 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.
- package/LICENSE.md +3 -266
- package/dist/browser.d.ts +16 -4
- package/dist/browser.js +5 -4
- package/dist/child.js +12 -17
- package/dist/{chunk-api-setup.ac7748ac.js → chunk-api-setup.6662587e.js} +65 -51
- package/dist/{chunk-install-pkg.863031f2.js → chunk-install-pkg.6450b372.js} +33 -32
- package/dist/chunk-integrations-globals.d419838f.js +26 -0
- package/dist/{chunk-node-git.ed5bded8.js → chunk-node-git.4c43bd73.js} +4 -2
- package/dist/cli-wrapper.js +6 -5
- package/dist/cli.js +27 -26
- package/dist/config.cjs +15 -7
- package/dist/config.d.ts +15 -8
- package/dist/config.js +10 -6
- package/dist/coverage.d.ts +5 -2
- package/dist/coverage.js +6 -0
- package/dist/entry.js +35 -34
- package/dist/environments.d.ts +5 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +17 -21
- package/dist/index.js +9 -10
- package/dist/loader.js +396 -12
- package/dist/node.d.ts +9 -7
- package/dist/node.js +28 -30
- package/dist/runners.d.ts +5 -2
- package/dist/runners.js +34 -30
- package/dist/{types-fafda418.d.ts → types-f03c83c4.d.ts} +243 -317
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -0
- package/dist/{chunk-node-pkg.f9696901.js → vendor-cli-api.c04eaa34.js} +3858 -5514
- package/dist/vendor-constants.538d9b49.js +54 -0
- package/dist/{chunk-integrations-coverage.e0a6acd2.js → vendor-coverage.a585b712.js} +5 -5
- package/dist/{chunk-runtime-mocker.344fec90.js → vendor-execute.8eaab47b.js} +9 -12
- package/dist/vendor-global.6795f91f.js +8 -0
- package/dist/vendor-index.4f82d248.js +161 -0
- package/dist/{chunk-env-node.affdd278.js → vendor-index.75f2b63d.js} +9 -2
- package/dist/{chunk-integrations-utils.d7c85bd9.js → vendor-index.81b9e499.js} +22 -21
- package/dist/{vendor-index.2cbcdd1e.js → vendor-index.c1e09929.js} +458 -373
- package/dist/vendor-index.fad2598b.js +44 -0
- package/dist/{vendor-index.534e612c.js → vendor-index.fc98d30f.js} +2 -2
- package/dist/{chunk-runtime-inspector.b1427a10.js → vendor-inspector.47fc8cbb.js} +5 -2
- package/dist/{chunk-runtime-rpc.1b5714dc.js → vendor-rpc.4d3d7a54.js} +5 -5
- package/dist/{chunk-integrations-run-once.a2b4758b.js → vendor-run-once.69ce7172.js} +3 -2
- package/dist/{chunk-runtime-setup.a49dc2f9.js → vendor-setup.common.cef38f4e.js} +2 -2
- package/dist/vendor-tasks.042d6084.js +14 -0
- package/dist/{chunk-utils-import.39ffe9c5.js → vendor-vi.a3ff54b1.js} +262 -3147
- package/dist/worker.js +13 -19
- package/package.json +40 -34
- package/utils.d.ts +1 -0
- package/dist/chunk-constants.bc18a549.js +0 -36
- package/dist/chunk-integrations-globals.a473e88a.js +0 -27
- package/dist/chunk-snapshot-env.a347d647.js +0 -11
- package/dist/chunk-utils-base.81f83dbd.js +0 -88
- package/dist/chunk-utils-env.04ffbef7.js +0 -70
- package/dist/chunk-utils-tasks.b41c8284.js +0 -107
- package/dist/env-afee91f0.d.ts +0 -10
- package/dist/vendor-index.783e7f3e.js +0 -71
- package/dist/vendor-index.bdee400f.js +0 -396
- package/dist/vendor-magic-string.es.b3bc5745.js +0 -1591
- /package/dist/{vendor-_commonjsHelpers.addc3445.js → vendor-_commonjsHelpers.76cdd49e.js} +0 -0
- /package/dist/{chunk-paths.e36446b4.js → vendor-paths.84fc7a99.js} +0 -0
package/dist/loader.js
CHANGED
|
@@ -1,21 +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 { g as getWorkerState } from './chunk-utils-env.04ffbef7.js';
|
|
6
3
|
import 'acorn';
|
|
7
|
-
import 'node:module';
|
|
4
|
+
import { builtinModules } from 'node:module';
|
|
8
5
|
import 'node:fs';
|
|
9
6
|
import 'pathe';
|
|
10
|
-
import 'node:assert';
|
|
11
|
-
import 'node:process';
|
|
7
|
+
import assert from 'node:assert';
|
|
8
|
+
import process$1 from 'node:process';
|
|
12
9
|
import 'node:path';
|
|
13
|
-
import 'node:v8';
|
|
14
|
-
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';
|
|
15
15
|
import 'std-env';
|
|
16
16
|
import '@vitest/runner/utils';
|
|
17
17
|
import '@vitest/utils';
|
|
18
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
|
+
|
|
19
403
|
var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
|
|
20
404
|
ModuleFormat2["Builtin"] = "builtin";
|
|
21
405
|
ModuleFormat2["Commonjs"] = "commonjs";
|
|
@@ -30,7 +414,7 @@ function hasESMSyntax(code) {
|
|
|
30
414
|
return ESM_RE.test(code);
|
|
31
415
|
}
|
|
32
416
|
const cache = /* @__PURE__ */ new Map();
|
|
33
|
-
|
|
417
|
+
async function getPotentialSource(filepath, result) {
|
|
34
418
|
var _a;
|
|
35
419
|
if (!result.url.startsWith("file://") || result.format === "module")
|
|
36
420
|
return null;
|
|
@@ -38,15 +422,15 @@ const getPotentialSource = async (filepath, result) => {
|
|
|
38
422
|
if (source == null)
|
|
39
423
|
source = await readFile(filepath, "utf8");
|
|
40
424
|
return source;
|
|
41
|
-
}
|
|
42
|
-
|
|
425
|
+
}
|
|
426
|
+
function detectESM(url, source) {
|
|
43
427
|
const cached = cache.get(url);
|
|
44
428
|
if (cached)
|
|
45
429
|
return cached.isPseudoESM;
|
|
46
430
|
if (!source)
|
|
47
431
|
return false;
|
|
48
432
|
return hasESMSyntax(source) && !hasCJSSyntax(source);
|
|
49
|
-
}
|
|
433
|
+
}
|
|
50
434
|
const resolve = async (url, context, next) => {
|
|
51
435
|
const { parentURL } = context;
|
|
52
436
|
const state = getWorkerState();
|
package/dist/node.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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:
|
|
70
|
-
sort(files:
|
|
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,16 +1,17 @@
|
|
|
1
|
-
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './
|
|
2
|
-
export { V as VitestExecutor } from './
|
|
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 './
|
|
5
|
-
import './
|
|
6
|
-
import '
|
|
7
|
-
import './chunk-env-node.affdd278.js';
|
|
4
|
+
import './vendor-constants.538d9b49.js';
|
|
5
|
+
import './vendor-coverage.a585b712.js';
|
|
6
|
+
import './vendor-index.75f2b63d.js';
|
|
8
7
|
import 'node:console';
|
|
8
|
+
import 'local-pkg';
|
|
9
9
|
import 'picocolors';
|
|
10
|
-
import './
|
|
10
|
+
import './vendor-index.fad2598b.js';
|
|
11
11
|
import 'std-env';
|
|
12
12
|
import '@vitest/runner/utils';
|
|
13
13
|
import '@vitest/utils';
|
|
14
|
+
import './vendor-global.6795f91f.js';
|
|
14
15
|
import 'vite';
|
|
15
16
|
import 'node:path';
|
|
16
17
|
import 'node:url';
|
|
@@ -22,39 +23,36 @@ import 'util';
|
|
|
22
23
|
import 'stream';
|
|
23
24
|
import 'events';
|
|
24
25
|
import 'fs';
|
|
25
|
-
import './vendor-_commonjsHelpers.
|
|
26
|
+
import './vendor-_commonjsHelpers.76cdd49e.js';
|
|
26
27
|
import 'vite-node/utils';
|
|
27
28
|
import 'vite-node/client';
|
|
28
|
-
import '
|
|
29
|
-
import './vendor-
|
|
30
|
-
import 'node:
|
|
29
|
+
import '@vitest/snapshot/manager';
|
|
30
|
+
import './vendor-paths.84fc7a99.js';
|
|
31
|
+
import 'node:v8';
|
|
31
32
|
import 'node:child_process';
|
|
32
|
-
import '
|
|
33
|
+
import './vendor-index.4f82d248.js';
|
|
34
|
+
import 'node:worker_threads';
|
|
33
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';
|
|
34
44
|
import 'assert';
|
|
35
45
|
import 'buffer';
|
|
46
|
+
import 'node:util';
|
|
47
|
+
import 'node:fs/promises';
|
|
36
48
|
import 'source-map';
|
|
37
49
|
import 'module';
|
|
38
50
|
import 'acorn';
|
|
39
51
|
import 'acorn-walk';
|
|
40
|
-
import '
|
|
41
|
-
import 'crypto';
|
|
42
|
-
import './chunk-paths.e36446b4.js';
|
|
43
|
-
import 'node:v8';
|
|
44
|
-
import './vendor-index.783e7f3e.js';
|
|
45
|
-
import 'node:worker_threads';
|
|
46
|
-
import 'tinypool';
|
|
47
|
-
import 'perf_hooks';
|
|
48
|
-
import './chunk-utils-tasks.b41c8284.js';
|
|
49
|
-
import '@vitest/utils/diff';
|
|
50
|
-
import 'vite-node/server';
|
|
51
|
-
import './vendor-magic-string.es.b3bc5745.js';
|
|
52
|
-
import 'node:module';
|
|
53
|
-
import 'node:crypto';
|
|
52
|
+
import 'magic-string';
|
|
54
53
|
import 'strip-literal';
|
|
54
|
+
import 'vite-node/server';
|
|
55
|
+
import 'node:readline';
|
|
55
56
|
import 'readline';
|
|
56
|
-
import './vendor-index.bdee400f.js';
|
|
57
|
-
import 'node:assert';
|
|
58
|
-
import 'node:util';
|
|
59
57
|
import '@vitest/spy';
|
|
60
|
-
import './
|
|
58
|
+
import './vendor-rpc.4d3d7a54.js';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { VitestRunner, VitestRunnerImportSource, Suite, Test, TestContext } from '@vitest/runner';
|
|
2
|
-
import { a as ResolvedConfig } from './types-
|
|
2
|
+
import { a as ResolvedConfig } from './types-f03c83c4.js';
|
|
3
3
|
import '@vitest/expect';
|
|
4
|
+
import '@vitest/snapshot';
|
|
4
5
|
import 'vite';
|
|
5
6
|
import '@vitest/runner/types';
|
|
6
7
|
import '@vitest/runner/utils';
|
|
7
8
|
import '@vitest/utils';
|
|
8
9
|
import 'tinybench';
|
|
9
10
|
import 'vite-node/client';
|
|
11
|
+
import '@vitest/snapshot/manager';
|
|
10
12
|
import 'node:worker_threads';
|
|
11
13
|
import 'vite-node';
|
|
12
14
|
import 'source-map';
|
|
13
|
-
import 'node:fs';
|
|
14
15
|
import 'vite-node/server';
|
|
16
|
+
import 'node:fs';
|
|
17
|
+
import 'chai';
|
|
15
18
|
|
|
16
19
|
declare class VitestTestRunner implements VitestRunner {
|
|
17
20
|
config: ResolvedConfig;
|