vitest 0.34.1 → 0.34.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.
- package/LICENSE.md +28 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/child.js +11 -6
- package/dist/{chunk-api-setup.644415c3.js → chunk-api-setup.cc5282f7.js} +25 -15
- package/dist/{chunk-install-pkg.dd40cbef.js → chunk-install-pkg.7e19b3a0.js} +6 -3
- package/dist/{chunk-integrations-globals.877c84db.js → chunk-integrations-globals.522ae1ae.js} +4 -3
- package/dist/cli.js +6 -3
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/entry-vm.js +4 -3
- package/dist/entry.js +4 -3
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +11 -2
- package/dist/execute.d.ts +139 -0
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.js +5 -4
- package/dist/loader.js +9 -528
- package/dist/node.d.ts +2 -2
- package/dist/node.js +6 -3
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +3 -2
- package/dist/{types-3c7dbfa5.d.ts → types-63abf2e0.d.ts} +63 -2
- package/dist/{vendor-environments.443ecd82.js → vendor-environments.37f266a9.js} +13 -6
- package/dist/{vendor-execute.9ab1c1a7.js → vendor-execute.4fc8203a.js} +409 -206
- package/dist/vendor-index.0b5b3600.js +2062 -0
- package/dist/{vendor-index.eff408fd.js → vendor-index.b5efbd68.js} +1 -1
- package/dist/{vendor-node.caa511fc.js → vendor-node.7b1bd3c5.js} +194 -121
- package/dist/vendor-tasks.f9d75aed.js +14 -0
- package/dist/{vendor-vi.271667ef.js → vendor-vi.f8055ff2.js} +2 -1
- package/dist/vm.js +14 -6
- package/dist/worker.js +12 -6
- package/package.json +7 -7
- package/dist/vendor-source-map.e6c1997b.js +0 -747
package/dist/loader.js
CHANGED
|
@@ -1,541 +1,22 @@
|
|
|
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.0b5b3600.js';
|
|
4
|
+
import { normalizeModuleId } from 'vite-node/utils';
|
|
5
|
+
import './vendor-index.087d1af7.js';
|
|
6
|
+
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
3
7
|
import 'acorn';
|
|
4
|
-
import
|
|
8
|
+
import 'node:module';
|
|
5
9
|
import 'node:fs';
|
|
6
10
|
import 'pathe';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
11
|
+
import 'node:assert';
|
|
12
|
+
import 'node:process';
|
|
9
13
|
import 'node:path';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { normalizeModuleId } from 'vite-node/utils';
|
|
13
|
-
import './vendor-index.087d1af7.js';
|
|
14
|
-
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
14
|
+
import 'node:v8';
|
|
15
|
+
import 'node:util';
|
|
15
16
|
import 'std-env';
|
|
16
17
|
import '@vitest/runner/utils';
|
|
17
18
|
import '@vitest/utils';
|
|
18
19
|
|
|
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
|
-
|
|
33
|
-
const isWindows = process$1.platform === 'win32';
|
|
34
|
-
|
|
35
|
-
const own$1 = {}.hasOwnProperty;
|
|
36
|
-
|
|
37
|
-
const classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
38
|
-
// Sorted by a rough estimate on most frequently used entries.
|
|
39
|
-
const kTypes = new Set([
|
|
40
|
-
'string',
|
|
41
|
-
'function',
|
|
42
|
-
'number',
|
|
43
|
-
'object',
|
|
44
|
-
// Accept 'Function' and 'Object' as alternative to the lower cased version.
|
|
45
|
-
'Function',
|
|
46
|
-
'Object',
|
|
47
|
-
'boolean',
|
|
48
|
-
'bigint',
|
|
49
|
-
'symbol'
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
|
|
54
|
-
* We cannot use Intl.ListFormat because it's not available in
|
|
55
|
-
* --without-intl builds.
|
|
56
|
-
*
|
|
57
|
-
* @param {Array<string>} array
|
|
58
|
-
* An array of strings.
|
|
59
|
-
* @param {string} [type]
|
|
60
|
-
* The list type to be inserted before the last element.
|
|
61
|
-
* @returns {string}
|
|
62
|
-
*/
|
|
63
|
-
function formatList(array, type = 'and') {
|
|
64
|
-
return array.length < 3
|
|
65
|
-
? array.join(` ${type} `)
|
|
66
|
-
: `${array.slice(0, -1).join(', ')}, ${type} ${array[array.length - 1]}`
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** @type {Map<string, MessageFunction | string>} */
|
|
70
|
-
const messages = new Map();
|
|
71
|
-
const nodeInternalPrefix = '__node_internal_';
|
|
72
|
-
/** @type {number} */
|
|
73
|
-
let userStackTraceLimit;
|
|
74
|
-
|
|
75
|
-
createError(
|
|
76
|
-
'ERR_INVALID_ARG_TYPE',
|
|
77
|
-
/**
|
|
78
|
-
* @param {string} name
|
|
79
|
-
* @param {Array<string> | string} expected
|
|
80
|
-
* @param {unknown} actual
|
|
81
|
-
*/
|
|
82
|
-
(name, expected, actual) => {
|
|
83
|
-
assert(typeof name === 'string', "'name' must be a string");
|
|
84
|
-
if (!Array.isArray(expected)) {
|
|
85
|
-
expected = [expected];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let message = 'The ';
|
|
89
|
-
if (name.endsWith(' argument')) {
|
|
90
|
-
// For cases like 'first argument'
|
|
91
|
-
message += `${name} `;
|
|
92
|
-
} else {
|
|
93
|
-
const type = name.includes('.') ? 'property' : 'argument';
|
|
94
|
-
message += `"${name}" ${type} `;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
message += 'must be ';
|
|
98
|
-
|
|
99
|
-
/** @type {Array<string>} */
|
|
100
|
-
const types = [];
|
|
101
|
-
/** @type {Array<string>} */
|
|
102
|
-
const instances = [];
|
|
103
|
-
/** @type {Array<string>} */
|
|
104
|
-
const other = [];
|
|
105
|
-
|
|
106
|
-
for (const value of expected) {
|
|
107
|
-
assert(
|
|
108
|
-
typeof value === 'string',
|
|
109
|
-
'All expected entries have to be of type string'
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
if (kTypes.has(value)) {
|
|
113
|
-
types.push(value.toLowerCase());
|
|
114
|
-
} else if (classRegExp.exec(value) === null) {
|
|
115
|
-
assert(
|
|
116
|
-
value !== 'object',
|
|
117
|
-
'The value "object" should be written as "Object"'
|
|
118
|
-
);
|
|
119
|
-
other.push(value);
|
|
120
|
-
} else {
|
|
121
|
-
instances.push(value);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Special handle `object` in case other instances are allowed to outline
|
|
126
|
-
// the differences between each other.
|
|
127
|
-
if (instances.length > 0) {
|
|
128
|
-
const pos = types.indexOf('object');
|
|
129
|
-
if (pos !== -1) {
|
|
130
|
-
types.slice(pos, 1);
|
|
131
|
-
instances.push('Object');
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (types.length > 0) {
|
|
136
|
-
message += `${types.length > 1 ? 'one of type' : 'of type'} ${formatList(
|
|
137
|
-
types,
|
|
138
|
-
'or'
|
|
139
|
-
)}`;
|
|
140
|
-
if (instances.length > 0 || other.length > 0) message += ' or ';
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (instances.length > 0) {
|
|
144
|
-
message += `an instance of ${formatList(instances, 'or')}`;
|
|
145
|
-
if (other.length > 0) message += ' or ';
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (other.length > 0) {
|
|
149
|
-
if (other.length > 1) {
|
|
150
|
-
message += `one of ${formatList(other, 'or')}`;
|
|
151
|
-
} else {
|
|
152
|
-
if (other[0].toLowerCase() !== other[0]) message += 'an ';
|
|
153
|
-
message += `${other[0]}`;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
message += `. Received ${determineSpecificType(actual)}`;
|
|
158
|
-
|
|
159
|
-
return message
|
|
160
|
-
},
|
|
161
|
-
TypeError
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
createError(
|
|
165
|
-
'ERR_INVALID_MODULE_SPECIFIER',
|
|
166
|
-
/**
|
|
167
|
-
* @param {string} request
|
|
168
|
-
* @param {string} reason
|
|
169
|
-
* @param {string} [base]
|
|
170
|
-
*/
|
|
171
|
-
(request, reason, base = undefined) => {
|
|
172
|
-
return `Invalid module "${request}" ${reason}${
|
|
173
|
-
base ? ` imported from ${base}` : ''
|
|
174
|
-
}`
|
|
175
|
-
},
|
|
176
|
-
TypeError
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
createError(
|
|
180
|
-
'ERR_INVALID_PACKAGE_CONFIG',
|
|
181
|
-
/**
|
|
182
|
-
* @param {string} path
|
|
183
|
-
* @param {string} [base]
|
|
184
|
-
* @param {string} [message]
|
|
185
|
-
*/
|
|
186
|
-
(path, base, message) => {
|
|
187
|
-
return `Invalid package config ${path}${
|
|
188
|
-
base ? ` while importing ${base}` : ''
|
|
189
|
-
}${message ? `. ${message}` : ''}`
|
|
190
|
-
},
|
|
191
|
-
Error
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
createError(
|
|
195
|
-
'ERR_INVALID_PACKAGE_TARGET',
|
|
196
|
-
/**
|
|
197
|
-
* @param {string} pkgPath
|
|
198
|
-
* @param {string} key
|
|
199
|
-
* @param {unknown} target
|
|
200
|
-
* @param {boolean} [isImport=false]
|
|
201
|
-
* @param {string} [base]
|
|
202
|
-
*/
|
|
203
|
-
(pkgPath, key, target, isImport = false, base = undefined) => {
|
|
204
|
-
const relError =
|
|
205
|
-
typeof target === 'string' &&
|
|
206
|
-
!isImport &&
|
|
207
|
-
target.length > 0 &&
|
|
208
|
-
!target.startsWith('./');
|
|
209
|
-
if (key === '.') {
|
|
210
|
-
assert(isImport === false);
|
|
211
|
-
return (
|
|
212
|
-
`Invalid "exports" main target ${JSON.stringify(target)} defined ` +
|
|
213
|
-
`in the package config ${pkgPath}package.json${
|
|
214
|
-
base ? ` imported from ${base}` : ''
|
|
215
|
-
}${relError ? '; targets must start with "./"' : ''}`
|
|
216
|
-
)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return `Invalid "${
|
|
220
|
-
isImport ? 'imports' : 'exports'
|
|
221
|
-
}" target ${JSON.stringify(
|
|
222
|
-
target
|
|
223
|
-
)} defined for '${key}' in the package config ${pkgPath}package.json${
|
|
224
|
-
base ? ` imported from ${base}` : ''
|
|
225
|
-
}${relError ? '; targets must start with "./"' : ''}`
|
|
226
|
-
},
|
|
227
|
-
Error
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
createError(
|
|
231
|
-
'ERR_MODULE_NOT_FOUND',
|
|
232
|
-
/**
|
|
233
|
-
* @param {string} path
|
|
234
|
-
* @param {string} base
|
|
235
|
-
* @param {string} [type]
|
|
236
|
-
*/
|
|
237
|
-
(path, base, type = 'package') => {
|
|
238
|
-
return `Cannot find ${type} '${path}' imported from ${base}`
|
|
239
|
-
},
|
|
240
|
-
Error
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
createError(
|
|
244
|
-
'ERR_NETWORK_IMPORT_DISALLOWED',
|
|
245
|
-
"import of '%s' by %s is not supported: %s",
|
|
246
|
-
Error
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
createError(
|
|
250
|
-
'ERR_PACKAGE_IMPORT_NOT_DEFINED',
|
|
251
|
-
/**
|
|
252
|
-
* @param {string} specifier
|
|
253
|
-
* @param {string} packagePath
|
|
254
|
-
* @param {string} base
|
|
255
|
-
*/
|
|
256
|
-
(specifier, packagePath, base) => {
|
|
257
|
-
return `Package import specifier "${specifier}" is not defined${
|
|
258
|
-
packagePath ? ` in package ${packagePath}package.json` : ''
|
|
259
|
-
} imported from ${base}`
|
|
260
|
-
},
|
|
261
|
-
TypeError
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
createError(
|
|
265
|
-
'ERR_PACKAGE_PATH_NOT_EXPORTED',
|
|
266
|
-
/**
|
|
267
|
-
* @param {string} pkgPath
|
|
268
|
-
* @param {string} subpath
|
|
269
|
-
* @param {string} [base]
|
|
270
|
-
*/
|
|
271
|
-
(pkgPath, subpath, base = undefined) => {
|
|
272
|
-
if (subpath === '.')
|
|
273
|
-
return `No "exports" main defined in ${pkgPath}package.json${
|
|
274
|
-
base ? ` imported from ${base}` : ''
|
|
275
|
-
}`
|
|
276
|
-
return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${
|
|
277
|
-
base ? ` imported from ${base}` : ''
|
|
278
|
-
}`
|
|
279
|
-
},
|
|
280
|
-
Error
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
createError(
|
|
284
|
-
'ERR_UNSUPPORTED_DIR_IMPORT',
|
|
285
|
-
"Directory import '%s' is not supported " +
|
|
286
|
-
'resolving ES modules imported from %s',
|
|
287
|
-
Error
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
createError(
|
|
291
|
-
'ERR_UNKNOWN_FILE_EXTENSION',
|
|
292
|
-
/**
|
|
293
|
-
* @param {string} ext
|
|
294
|
-
* @param {string} path
|
|
295
|
-
*/
|
|
296
|
-
(ext, path) => {
|
|
297
|
-
return `Unknown file extension "${ext}" for ${path}`
|
|
298
|
-
},
|
|
299
|
-
TypeError
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
createError(
|
|
303
|
-
'ERR_INVALID_ARG_VALUE',
|
|
304
|
-
/**
|
|
305
|
-
* @param {string} name
|
|
306
|
-
* @param {unknown} value
|
|
307
|
-
* @param {string} [reason='is invalid']
|
|
308
|
-
*/
|
|
309
|
-
(name, value, reason = 'is invalid') => {
|
|
310
|
-
let inspected = inspect(value);
|
|
311
|
-
|
|
312
|
-
if (inspected.length > 128) {
|
|
313
|
-
inspected = `${inspected.slice(0, 128)}...`;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const type = name.includes('.') ? 'property' : 'argument';
|
|
317
|
-
|
|
318
|
-
return `The ${type} '${name}' ${reason}. Received ${inspected}`
|
|
319
|
-
},
|
|
320
|
-
TypeError
|
|
321
|
-
// Note: extra classes have been shaken out.
|
|
322
|
-
// , RangeError
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
createError(
|
|
326
|
-
'ERR_UNSUPPORTED_ESM_URL_SCHEME',
|
|
327
|
-
/**
|
|
328
|
-
* @param {URL} url
|
|
329
|
-
* @param {Array<string>} supported
|
|
330
|
-
*/
|
|
331
|
-
(url, supported) => {
|
|
332
|
-
let message = `Only URLs with a scheme in: ${formatList(
|
|
333
|
-
supported
|
|
334
|
-
)} are supported by the default ESM loader`;
|
|
335
|
-
|
|
336
|
-
if (isWindows && url.protocol.length === 2) {
|
|
337
|
-
message += '. On Windows, absolute paths must be valid file:// URLs';
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
message += `. Received protocol '${url.protocol}'`;
|
|
341
|
-
return message
|
|
342
|
-
},
|
|
343
|
-
Error
|
|
344
|
-
);
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Utility function for registering the error codes. Only used here. Exported
|
|
348
|
-
* *only* to allow for testing.
|
|
349
|
-
* @param {string} sym
|
|
350
|
-
* @param {MessageFunction | string} value
|
|
351
|
-
* @param {ErrorConstructor} def
|
|
352
|
-
* @returns {new (...args: Array<any>) => Error}
|
|
353
|
-
*/
|
|
354
|
-
function createError(sym, value, def) {
|
|
355
|
-
// Special case for SystemError that formats the error message differently
|
|
356
|
-
// The SystemErrors only have SystemError as their base classes.
|
|
357
|
-
messages.set(sym, value);
|
|
358
|
-
|
|
359
|
-
return makeNodeErrorWithCode(def, sym)
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* @param {ErrorConstructor} Base
|
|
364
|
-
* @param {string} key
|
|
365
|
-
* @returns {ErrorConstructor}
|
|
366
|
-
*/
|
|
367
|
-
function makeNodeErrorWithCode(Base, key) {
|
|
368
|
-
// @ts-expect-error It’s a Node error.
|
|
369
|
-
return NodeError
|
|
370
|
-
/**
|
|
371
|
-
* @param {Array<unknown>} args
|
|
372
|
-
*/
|
|
373
|
-
function NodeError(...args) {
|
|
374
|
-
const limit = Error.stackTraceLimit;
|
|
375
|
-
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
|
376
|
-
const error = new Base();
|
|
377
|
-
// Reset the limit and setting the name property.
|
|
378
|
-
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
|
379
|
-
const message = getMessage(key, args, error);
|
|
380
|
-
Object.defineProperties(error, {
|
|
381
|
-
// Note: no need to implement `kIsNodeError` symbol, would be hard,
|
|
382
|
-
// probably.
|
|
383
|
-
message: {
|
|
384
|
-
value: message,
|
|
385
|
-
enumerable: false,
|
|
386
|
-
writable: true,
|
|
387
|
-
configurable: true
|
|
388
|
-
},
|
|
389
|
-
toString: {
|
|
390
|
-
/** @this {Error} */
|
|
391
|
-
value() {
|
|
392
|
-
return `${this.name} [${key}]: ${this.message}`
|
|
393
|
-
},
|
|
394
|
-
enumerable: false,
|
|
395
|
-
writable: true,
|
|
396
|
-
configurable: true
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
captureLargerStackTrace(error);
|
|
401
|
-
// @ts-expect-error It’s a Node error.
|
|
402
|
-
error.code = key;
|
|
403
|
-
return error
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* @returns {boolean}
|
|
409
|
-
*/
|
|
410
|
-
function isErrorStackTraceLimitWritable() {
|
|
411
|
-
// Do no touch Error.stackTraceLimit as V8 would attempt to install
|
|
412
|
-
// it again during deserialization.
|
|
413
|
-
try {
|
|
414
|
-
// @ts-expect-error: not in types?
|
|
415
|
-
if (v8.startupSnapshot.isBuildingSnapshot()) {
|
|
416
|
-
return false
|
|
417
|
-
}
|
|
418
|
-
} catch {}
|
|
419
|
-
|
|
420
|
-
const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit');
|
|
421
|
-
if (desc === undefined) {
|
|
422
|
-
return Object.isExtensible(Error)
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
return own$1.call(desc, 'writable') && desc.writable !== undefined
|
|
426
|
-
? desc.writable
|
|
427
|
-
: desc.set !== undefined
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* This function removes unnecessary frames from Node.js core errors.
|
|
432
|
-
* @template {(...args: unknown[]) => unknown} T
|
|
433
|
-
* @param {T} fn
|
|
434
|
-
* @returns {T}
|
|
435
|
-
*/
|
|
436
|
-
function hideStackFrames(fn) {
|
|
437
|
-
// We rename the functions that will be hidden to cut off the stacktrace
|
|
438
|
-
// at the outermost one
|
|
439
|
-
const hidden = nodeInternalPrefix + fn.name;
|
|
440
|
-
Object.defineProperty(fn, 'name', {value: hidden});
|
|
441
|
-
return fn
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
const captureLargerStackTrace = hideStackFrames(
|
|
445
|
-
/**
|
|
446
|
-
* @param {Error} error
|
|
447
|
-
* @returns {Error}
|
|
448
|
-
*/
|
|
449
|
-
// @ts-expect-error: fine
|
|
450
|
-
function (error) {
|
|
451
|
-
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
452
|
-
if (stackTraceLimitIsWritable) {
|
|
453
|
-
userStackTraceLimit = Error.stackTraceLimit;
|
|
454
|
-
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
Error.captureStackTrace(error);
|
|
458
|
-
|
|
459
|
-
// Reset the limit
|
|
460
|
-
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
461
|
-
|
|
462
|
-
return error
|
|
463
|
-
}
|
|
464
|
-
);
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* @param {string} key
|
|
468
|
-
* @param {Array<unknown>} args
|
|
469
|
-
* @param {Error} self
|
|
470
|
-
* @returns {string}
|
|
471
|
-
*/
|
|
472
|
-
function getMessage(key, args, self) {
|
|
473
|
-
const message = messages.get(key);
|
|
474
|
-
assert(message !== undefined, 'expected `message` to be found');
|
|
475
|
-
|
|
476
|
-
if (typeof message === 'function') {
|
|
477
|
-
assert(
|
|
478
|
-
message.length <= args.length, // Default options do not count.
|
|
479
|
-
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
|
480
|
-
`match the required ones (${message.length}).`
|
|
481
|
-
);
|
|
482
|
-
return Reflect.apply(message, self, args)
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const regex = /%[dfijoOs]/g;
|
|
486
|
-
let expectedLength = 0;
|
|
487
|
-
while (regex.exec(message) !== null) expectedLength++;
|
|
488
|
-
assert(
|
|
489
|
-
expectedLength === args.length,
|
|
490
|
-
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
|
491
|
-
`match the required ones (${expectedLength}).`
|
|
492
|
-
);
|
|
493
|
-
if (args.length === 0) return message
|
|
494
|
-
|
|
495
|
-
args.unshift(message);
|
|
496
|
-
return Reflect.apply(format, null, args)
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Determine the specific type of a value for type-mismatch errors.
|
|
501
|
-
* @param {unknown} value
|
|
502
|
-
* @returns {string}
|
|
503
|
-
*/
|
|
504
|
-
function determineSpecificType(value) {
|
|
505
|
-
if (value === null || value === undefined) {
|
|
506
|
-
return String(value)
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
if (typeof value === 'function' && value.name) {
|
|
510
|
-
return `function ${value.name}`
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
if (typeof value === 'object') {
|
|
514
|
-
if (value.constructor && value.constructor.name) {
|
|
515
|
-
return `an instance of ${value.constructor.name}`
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
return `${inspect(value, {depth: -1})}`
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
let inspected = inspect(value, {colors: false});
|
|
522
|
-
|
|
523
|
-
if (inspected.length > 28) {
|
|
524
|
-
inspected = `${inspected.slice(0, 25)}...`;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
return `type ${typeof value} (${inspected})`
|
|
528
|
-
}
|
|
529
|
-
function isNodeBuiltin(id = "") {
|
|
530
|
-
id = id.replace(/^node:/, "").split("/")[0];
|
|
531
|
-
return BUILTIN_MODULES.has(id);
|
|
532
|
-
}
|
|
533
|
-
pathToFileURL(process.cwd());
|
|
534
|
-
const CJS_RE = /([\s;]|^)(module.exports\b|exports\.\w|require\s*\(|global\.\w)/m;
|
|
535
|
-
function hasCJSSyntax(code) {
|
|
536
|
-
return CJS_RE.test(code);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
20
|
var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
|
|
540
21
|
ModuleFormat2["Builtin"] = "builtin";
|
|
541
22
|
ModuleFormat2["Commonjs"] = "commonjs";
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as VitestRunMode, U as UserConfig, e as Vitest, T as TestSequencer, W as WorkspaceSpec } from './types-
|
|
2
|
-
export { g as TestSequencerConstructor, f as VitestWorkspace, s as startVitest } from './types-
|
|
1
|
+
import { V as VitestRunMode, U as UserConfig, e as Vitest, T as TestSequencer, W as WorkspaceSpec } from './types-63abf2e0.js';
|
|
2
|
+
export { g as TestSequencerConstructor, f as VitestWorkspace, s as startVitest } from './types-63abf2e0.js';
|
|
3
3
|
import { UserConfig as UserConfig$1, Plugin } from 'vite';
|
|
4
4
|
import '@vitest/snapshot';
|
|
5
5
|
import '@vitest/expect';
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-node.
|
|
1
|
+
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-node.7b1bd3c5.js';
|
|
2
2
|
import 'pathe';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'node:path';
|
|
@@ -34,7 +34,8 @@ import 'node:os';
|
|
|
34
34
|
import 'tinypool';
|
|
35
35
|
import 'local-pkg';
|
|
36
36
|
import 'node:perf_hooks';
|
|
37
|
-
import './vendor-
|
|
37
|
+
import './vendor-tasks.f9d75aed.js';
|
|
38
|
+
import '@vitest/utils/source-map';
|
|
38
39
|
import 'node:module';
|
|
39
40
|
import 'node:crypto';
|
|
40
41
|
import './vendor-index.1f85e5f1.js';
|
|
@@ -49,7 +50,9 @@ import 'acorn';
|
|
|
49
50
|
import 'acorn-walk';
|
|
50
51
|
import 'magic-string';
|
|
51
52
|
import 'strip-literal';
|
|
52
|
-
import './vendor-environments.
|
|
53
|
+
import './vendor-environments.37f266a9.js';
|
|
54
|
+
import './vendor-index.0b5b3600.js';
|
|
55
|
+
import 'node:assert';
|
|
53
56
|
import 'node:console';
|
|
54
57
|
import 'node:readline';
|
|
55
58
|
import 'readline';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
|
|
2
|
-
import { R as ResolvedConfig } from './types-
|
|
2
|
+
import { R as ResolvedConfig } from './types-63abf2e0.js';
|
|
3
3
|
import '@vitest/snapshot';
|
|
4
4
|
import '@vitest/expect';
|
|
5
5
|
import 'vite';
|
package/dist/runners.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
2
|
-
import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.f8055ff2.js';
|
|
3
3
|
import './vendor-index.087d1af7.js';
|
|
4
4
|
import { a as rpc } from './vendor-rpc.cbd8e972.js';
|
|
5
|
-
import { g as getFullName } from './vendor-
|
|
5
|
+
import { g as getFullName } from './vendor-tasks.f9d75aed.js';
|
|
6
6
|
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
7
7
|
import { getNames } from '@vitest/runner/utils';
|
|
8
8
|
import { performance } from 'node:perf_hooks';
|
|
@@ -12,6 +12,7 @@ import 'chai';
|
|
|
12
12
|
import './vendor-_commonjsHelpers.7d1333e8.js';
|
|
13
13
|
import '@vitest/snapshot';
|
|
14
14
|
import '@vitest/utils/error';
|
|
15
|
+
import '@vitest/utils/source-map';
|
|
15
16
|
import 'util';
|
|
16
17
|
import './vendor-date.6e993429.js';
|
|
17
18
|
import '@vitest/spy';
|