vitest 4.0.0-beta.11 → 4.0.0-beta.13
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 +4 -101
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +2 -2
- package/dist/chunks/{benchmark.LXhJ0F0X.js → benchmark.DHKMYAts.js} +1 -1
- package/dist/chunks/{browser.d.Dx7DO_Ce.d.ts → browser.d.D9YV3JvA.d.ts} +1 -1
- package/dist/chunks/{cac.elvK37c9.js → cac.BBtYKH7y.js} +16 -9
- package/dist/chunks/{cli-api.C7plPyhs.js → cli-api.CeakdBUN.js} +95 -148
- package/dist/chunks/{config.d.B_LthbQq.d.ts → config.d.DGazh2r6.d.ts} +3 -1
- package/dist/chunks/{console.CiTi59Jy.js → console.CTJL2nuH.js} +3 -5
- package/dist/chunks/{coverage.CG6Uhorw.js → coverage.DabP7UTQ.js} +69 -80
- package/dist/chunks/{creator.08Gi-vCA.js → creator.DfXDsUyL.js} +6 -8
- package/dist/chunks/{global.d.BK3X7FW1.d.ts → global.d.BcFPD2LN.d.ts} +0 -13
- package/dist/chunks/{globals.BjvYA-AD.js → globals.DC4ntO86.js} +5 -5
- package/dist/chunks/{index.DIWhzsUh.js → index.Bt-upxGS.js} +6 -12
- package/dist/chunks/{index.BwBttQPf.js → index.CHrBLuEH.js} +33 -38
- package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
- package/dist/chunks/{index.AZOjjqWP.js → index.Dnl38iQ_.js} +2 -2
- package/dist/chunks/{index.BhY64fF0.js → index.uLUz1RDt.js} +1 -1
- package/dist/chunks/{inspector.CvQD-Nie.js → inspector.Br76Q2Mb.js} +1 -4
- package/dist/chunks/{moduleRunner.d.BNa-CL9e.d.ts → moduleRunner.d.CeYc7nZ0.d.ts} +1 -1
- package/dist/chunks/{node.BsdMi6DV.js → node.BwAWWjHZ.js} +2 -3
- package/dist/chunks/{plugin.d.C5phQR6o.d.ts → plugin.d.COyglhiI.d.ts} +1 -1
- package/dist/chunks/{reporters.d.CVzhsTvK.d.ts → reporters.d.xGvTJYG3.d.ts} +41 -4
- package/dist/chunks/{resolveSnapshotEnvironment.DQVamkje.js → resolveSnapshotEnvironment.BsJpmVZR.js} +7 -8
- package/dist/chunks/{rpc.jKGRSXIH.js → rpc.cD77ENhU.js} +12 -13
- package/dist/chunks/{setup-common.NAWRuMRP.js → setup-common.BewgbkTd.js} +5 -5
- package/dist/chunks/{startModuleRunner.oAuCu1yL.js → startModuleRunner.DPBo3mme.js} +40 -48
- package/dist/chunks/{test.KC5tH8hC.js → test.CTuWuHYH.js} +5 -5
- package/dist/chunks/{typechecker.gXq-5P3n.js → typechecker.BfOQ86_a.js} +54 -77
- package/dist/chunks/{utils.DGKhod2J.js → utils.CG9h5ccR.js} +1 -4
- package/dist/chunks/{vi.CiJ0Laa6.js → vi.B2--mG9U.js} +35 -144
- package/dist/chunks/{worker.rPGLlbkW.js → worker.DVTUM2IW.js} +11 -15
- package/dist/chunks/{worker.d.B_Fd9M_w.d.ts → worker.d.buwuBpBt.d.ts} +1 -1
- package/dist/cli.js +3 -3
- package/dist/config.d.ts +6 -6
- package/dist/coverage.d.ts +5 -5
- package/dist/coverage.js +3 -3
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +5 -5
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +10 -12
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +8 -8
- package/dist/node.js +10 -10
- package/dist/reporters.d.ts +5 -5
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +6 -6
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker-base.js +30 -32
- package/dist/worker-vm.js +19 -30
- package/dist/workers/runVmTests.js +10 -10
- package/package.json +18 -19
package/dist/worker-vm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { c as createForksRpcOptions, u as unwrapSerializableConfig, a as createThreadsRpcOptions, e as execute, t as teardown$1 } from './chunks/worker.
|
|
1
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig, a as createThreadsRpcOptions, e as execute, t as teardown$1 } from './chunks/worker.DVTUM2IW.js';
|
|
2
2
|
import v8 from 'node:v8';
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import vm, { isContext, runInContext } from 'node:vm';
|
|
5
5
|
import { dirname, basename, extname, normalize, resolve } from 'pathe';
|
|
6
6
|
import { distDir } from './path.js';
|
|
7
|
-
import { createCustomConsole } from './chunks/console.
|
|
7
|
+
import { createCustomConsole } from './chunks/console.CTJL2nuH.js';
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import { createRequire, Module, isBuiltin } from 'node:module';
|
|
10
10
|
import { toArray, isBareImport } from '@vitest/utils/helpers';
|
|
@@ -12,14 +12,14 @@ import { findNearestPackageData } from '@vitest/utils/resolver';
|
|
|
12
12
|
import { dirname as dirname$1 } from 'node:path';
|
|
13
13
|
import { CSS_LANGS_RE, KNOWN_ASSET_RE } from '@vitest/utils/constants';
|
|
14
14
|
import { getDefaultRequestStubs } from './module-evaluator.js';
|
|
15
|
-
import { s as startVitestModuleRunner, c as createNodeImportMeta, a as VITEST_VM_CONTEXT_SYMBOL } from './chunks/startModuleRunner.
|
|
16
|
-
import { p as provideWorkerState } from './chunks/utils.
|
|
15
|
+
import { s as startVitestModuleRunner, c as createNodeImportMeta, a as VITEST_VM_CONTEXT_SYMBOL } from './chunks/startModuleRunner.DPBo3mme.js';
|
|
16
|
+
import { p as provideWorkerState } from './chunks/utils.CG9h5ccR.js';
|
|
17
17
|
import '@vitest/utils/source-map';
|
|
18
18
|
import 'vite/module-runner';
|
|
19
|
-
import './chunks/index.
|
|
19
|
+
import './chunks/index.Bt-upxGS.js';
|
|
20
20
|
import 'node:console';
|
|
21
|
-
import './chunks/inspector.
|
|
22
|
-
import './chunks/rpc.
|
|
21
|
+
import './chunks/inspector.Br76Q2Mb.js';
|
|
22
|
+
import './chunks/rpc.cD77ENhU.js';
|
|
23
23
|
import '@vitest/utils/timers';
|
|
24
24
|
import './chunks/index.Bgo3tNWt.js';
|
|
25
25
|
import 'node:stream';
|
|
@@ -51,8 +51,7 @@ function interopCommonJsModule(interopDefault, mod) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
function isPrimitive(obj) {
|
|
54
|
-
|
|
55
|
-
return !isObject;
|
|
54
|
+
return !(obj != null && (typeof obj === "object" || typeof obj === "function"));
|
|
56
55
|
}
|
|
57
56
|
const SyntheticModule = vm.SyntheticModule;
|
|
58
57
|
const SourceTextModule = vm.SourceTextModule;
|
|
@@ -121,8 +120,7 @@ class CommonjsExecutor {
|
|
|
121
120
|
}
|
|
122
121
|
// exposed for external use, Node.js does the opposite
|
|
123
122
|
static _load = (request, parent, _isMain) => {
|
|
124
|
-
|
|
125
|
-
return require(request);
|
|
123
|
+
return Module$1.createRequire(parent?.filename ?? request)(request);
|
|
126
124
|
};
|
|
127
125
|
static wrap = (script) => {
|
|
128
126
|
return Module$1.wrapper[0] + script + Module$1.wrapper[1];
|
|
@@ -172,8 +170,8 @@ class CommonjsExecutor {
|
|
|
172
170
|
};
|
|
173
171
|
createRequire = (filename) => {
|
|
174
172
|
const _require = createRequire(filename), require = ((id) => {
|
|
175
|
-
const resolved = _require.resolve(id)
|
|
176
|
-
if (
|
|
173
|
+
const resolved = _require.resolve(id);
|
|
174
|
+
if (extname(resolved) === ".node" || isBuiltin(resolved)) return this.requireCoreModule(resolved);
|
|
177
175
|
const module = new this.Module(resolved);
|
|
178
176
|
return this.loadCommonJSModule(module, resolved);
|
|
179
177
|
});
|
|
@@ -203,8 +201,8 @@ class CommonjsExecutor {
|
|
|
203
201
|
loadCommonJSModule(module, filename) {
|
|
204
202
|
const cached = this.requireCache.get(filename);
|
|
205
203
|
if (cached) return cached.exports;
|
|
206
|
-
const extension = this.findLongestRegisteredExtension(filename)
|
|
207
|
-
return
|
|
204
|
+
const extension = this.findLongestRegisteredExtension(filename);
|
|
205
|
+
return (this.extensions[extension] || this.extensions[".js"])(module, filename), module.exports;
|
|
208
206
|
}
|
|
209
207
|
findLongestRegisteredExtension(filename) {
|
|
210
208
|
const name = basename(filename);
|
|
@@ -275,8 +273,7 @@ class CommonjsExecutor {
|
|
|
275
273
|
// return namedExports
|
|
276
274
|
// }
|
|
277
275
|
require(identifier) {
|
|
278
|
-
|
|
279
|
-
if (ext === ".node" || isBuiltin(identifier)) return this.requireCoreModule(identifier);
|
|
276
|
+
if (extname(identifier) === ".node" || isBuiltin(identifier)) return this.requireCoreModule(identifier);
|
|
280
277
|
const module = new this.Module(identifier);
|
|
281
278
|
return this.loadCommonJSModule(module, identifier);
|
|
282
279
|
}
|
|
@@ -361,7 +358,8 @@ class EsmExecutor {
|
|
|
361
358
|
if (cached) return cached;
|
|
362
359
|
const wasmModule = await WebAssembly.compile(source), exports = WebAssembly.Module.exports(wasmModule), imports = WebAssembly.Module.imports(wasmModule), moduleLookup = {};
|
|
363
360
|
for (const { module } of imports) if (moduleLookup[module] === void 0) moduleLookup[module] = await this.executor.resolveModule(module, identifier);
|
|
364
|
-
const evaluateModule = (module) => this.evaluateModule(module)
|
|
361
|
+
const evaluateModule = (module) => this.evaluateModule(module);
|
|
362
|
+
return new SyntheticModule(exports.map(({ name }) => name), async function() {
|
|
365
363
|
const importsObject = {};
|
|
366
364
|
for (const { module, name } of imports) {
|
|
367
365
|
if (!importsObject[module]) importsObject[module] = {};
|
|
@@ -373,7 +371,6 @@ class EsmExecutor {
|
|
|
373
371
|
context: this.context,
|
|
374
372
|
identifier
|
|
375
373
|
});
|
|
376
|
-
return syntheticModule;
|
|
377
374
|
}
|
|
378
375
|
cacheModule(identifier, module) {
|
|
379
376
|
this.moduleCache.set(identifier, module);
|
|
@@ -432,9 +429,7 @@ class ViteExecutor {
|
|
|
432
429
|
return this.options.context.__vitest_worker__;
|
|
433
430
|
}
|
|
434
431
|
async createViteModule(fileUrl) {
|
|
435
|
-
|
|
436
|
-
const cached = this.esm.resolveCachedModule(fileUrl);
|
|
437
|
-
return cached || this.esm.createEsModule(fileUrl, async () => {
|
|
432
|
+
return fileUrl === CLIENT_FILE || fileUrl === CLIENT_ID ? this.createViteClientModule() : this.esm.resolveCachedModule(fileUrl) || this.esm.createEsModule(fileUrl, async () => {
|
|
438
433
|
try {
|
|
439
434
|
const result = await this.options.transform(fileUrl);
|
|
440
435
|
if (result.code) return result.code;
|
|
@@ -545,10 +540,7 @@ class ExternalModulesExecutor {
|
|
|
545
540
|
// still experimental on NodeJS --experimental-wasm-modules
|
|
546
541
|
// cf. ESM_FILE_FORMAT(url) in https://nodejs.org/docs/latest-v20.x/api/esm.html#resolution-algorithm
|
|
547
542
|
type = "wasm";
|
|
548
|
-
else
|
|
549
|
-
const pkgData = findNearestPackageData(normalize(pathUrl));
|
|
550
|
-
type = pkgData.type === "module" ? "module" : "commonjs";
|
|
551
|
-
}
|
|
543
|
+
else type = findNearestPackageData(normalize(pathUrl)).type === "module" ? "module" : "commonjs";
|
|
552
544
|
return {
|
|
553
545
|
type,
|
|
554
546
|
path: pathUrl,
|
|
@@ -571,10 +563,7 @@ class ExternalModulesExecutor {
|
|
|
571
563
|
case "module": return this.esm.createEsModule(url, () => this.fs.readFileAsync(path));
|
|
572
564
|
case "commonjs": return this.cjs.getCjsSyntheticModule(path, identifier);
|
|
573
565
|
case "network": return this.esm.createNetworkModule(url);
|
|
574
|
-
default:
|
|
575
|
-
const _deadend = type;
|
|
576
|
-
return _deadend;
|
|
577
|
-
}
|
|
566
|
+
default: return type;
|
|
578
567
|
}
|
|
579
568
|
}
|
|
580
569
|
get isNetworkSupported() {
|
|
@@ -5,19 +5,19 @@ import timersPromises from 'node:timers/promises';
|
|
|
5
5
|
import util from 'node:util';
|
|
6
6
|
import { startTests, collectTests } from '@vitest/runner';
|
|
7
7
|
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
|
|
8
|
-
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/resolveSnapshotEnvironment.
|
|
9
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.
|
|
10
|
-
import { i as index } from '../chunks/index.
|
|
11
|
-
import { c as closeInspector } from '../chunks/inspector.
|
|
12
|
-
import { g as getWorkerState } from '../chunks/utils.
|
|
13
|
-
import { g as globalExpect } from '../chunks/vi.
|
|
8
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/resolveSnapshotEnvironment.BsJpmVZR.js';
|
|
9
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.BewgbkTd.js';
|
|
10
|
+
import { i as index } from '../chunks/index.Dnl38iQ_.js';
|
|
11
|
+
import { c as closeInspector } from '../chunks/inspector.Br76Q2Mb.js';
|
|
12
|
+
import { g as getWorkerState } from '../chunks/utils.CG9h5ccR.js';
|
|
13
|
+
import { g as globalExpect } from '../chunks/vi.B2--mG9U.js';
|
|
14
14
|
import '@vitest/expect';
|
|
15
|
-
import '../chunks/rpc.
|
|
15
|
+
import '../chunks/rpc.cD77ENhU.js';
|
|
16
16
|
import '@vitest/utils/timers';
|
|
17
17
|
import '../chunks/index.Bgo3tNWt.js';
|
|
18
|
-
import '../chunks/test.
|
|
18
|
+
import '../chunks/test.CTuWuHYH.js';
|
|
19
19
|
import '@vitest/utils/helpers';
|
|
20
|
-
import '../chunks/benchmark.
|
|
20
|
+
import '../chunks/benchmark.DHKMYAts.js';
|
|
21
21
|
import '@vitest/runner/utils';
|
|
22
22
|
import '@vitest/utils/error';
|
|
23
23
|
import 'pathe';
|
|
@@ -26,10 +26,10 @@ import '@vitest/snapshot';
|
|
|
26
26
|
import 'expect-type';
|
|
27
27
|
import 'vite/module-runner';
|
|
28
28
|
import 'node:url';
|
|
29
|
-
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
30
29
|
import '@vitest/spy';
|
|
31
30
|
import '@vitest/utils/offset';
|
|
32
31
|
import '@vitest/utils/source-map';
|
|
32
|
+
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
33
33
|
import '../chunks/date.-jtEtIeV.js';
|
|
34
34
|
|
|
35
35
|
async function run(method, files, config, moduleRunner) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.13",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://opencollective.com/vitest",
|
|
9
|
-
"homepage": "https://
|
|
9
|
+
"homepage": "https://vitest.dev",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git+https://github.com/vitest-dev/vitest.git",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"dist"
|
|
118
118
|
],
|
|
119
119
|
"engines": {
|
|
120
|
-
"node": "^
|
|
120
|
+
"node": "^20.0.0 || ^22.0.0 || >=24.0.0"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"@edge-runtime/vm": "*",
|
|
@@ -125,8 +125,8 @@
|
|
|
125
125
|
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
|
126
126
|
"happy-dom": "*",
|
|
127
127
|
"jsdom": "*",
|
|
128
|
-
"@vitest/
|
|
129
|
-
"@vitest/
|
|
128
|
+
"@vitest/ui": "4.0.0-beta.13",
|
|
129
|
+
"@vitest/browser": "4.0.0-beta.13"
|
|
130
130
|
},
|
|
131
131
|
"peerDependenciesMeta": {
|
|
132
132
|
"@edge-runtime/vm": {
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
}
|
|
153
153
|
},
|
|
154
154
|
"dependencies": {
|
|
155
|
-
"debug": "^4.4.
|
|
155
|
+
"debug": "^4.4.3",
|
|
156
156
|
"es-module-lexer": "^1.7.0",
|
|
157
157
|
"expect-type": "^1.2.2",
|
|
158
158
|
"magic-string": "^0.30.19",
|
|
@@ -166,44 +166,43 @@
|
|
|
166
166
|
"tinyrainbow": "^3.0.3",
|
|
167
167
|
"vite": "^6.0.0 || ^7.0.0-0",
|
|
168
168
|
"why-is-node-running": "^2.3.0",
|
|
169
|
-
"@vitest/
|
|
170
|
-
"@vitest/
|
|
171
|
-
"@vitest/
|
|
172
|
-
"@vitest/
|
|
173
|
-
"@vitest/spy": "4.0.0-beta.
|
|
174
|
-
"@vitest/utils": "4.0.0-beta.
|
|
175
|
-
"@vitest/
|
|
169
|
+
"@vitest/mocker": "4.0.0-beta.13",
|
|
170
|
+
"@vitest/expect": "4.0.0-beta.13",
|
|
171
|
+
"@vitest/snapshot": "4.0.0-beta.13",
|
|
172
|
+
"@vitest/runner": "4.0.0-beta.13",
|
|
173
|
+
"@vitest/spy": "4.0.0-beta.13",
|
|
174
|
+
"@vitest/utils": "4.0.0-beta.13",
|
|
175
|
+
"@vitest/pretty-format": "4.0.0-beta.13"
|
|
176
176
|
},
|
|
177
177
|
"devDependencies": {
|
|
178
178
|
"@antfu/install-pkg": "^1.1.0",
|
|
179
179
|
"@edge-runtime/vm": "^5.0.0",
|
|
180
|
-
"@jridgewell/trace-mapping": "0.3.
|
|
180
|
+
"@jridgewell/trace-mapping": "0.3.31",
|
|
181
181
|
"@sinonjs/fake-timers": "14.0.0",
|
|
182
182
|
"@types/debug": "^4.1.12",
|
|
183
183
|
"@types/estree": "^1.0.8",
|
|
184
184
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
185
185
|
"@types/istanbul-reports": "^3.0.4",
|
|
186
186
|
"@types/jsdom": "^21.1.7",
|
|
187
|
-
"@types/node": "^22.18.
|
|
187
|
+
"@types/node": "^22.18.6",
|
|
188
188
|
"@types/picomatch": "^4.0.2",
|
|
189
189
|
"@types/prompts": "^2.4.9",
|
|
190
190
|
"@types/sinonjs__fake-timers": "^8.1.5",
|
|
191
191
|
"acorn-walk": "^8.3.4",
|
|
192
192
|
"birpc": "^2.5.0",
|
|
193
193
|
"cac": "^6.7.14",
|
|
194
|
-
"
|
|
195
|
-
"find-up": "^6.3.0",
|
|
194
|
+
"empathic": "^2.0.0",
|
|
196
195
|
"flatted": "^3.3.3",
|
|
197
196
|
"happy-dom": "^18.0.1",
|
|
198
197
|
"jsdom": "^26.1.0",
|
|
199
198
|
"local-pkg": "^1.1.2",
|
|
200
|
-
"mime": "^4.0
|
|
199
|
+
"mime": "^4.1.0",
|
|
201
200
|
"prompts": "^2.4.2",
|
|
202
201
|
"strip-literal": "^3.0.0",
|
|
203
202
|
"ws": "^8.18.3"
|
|
204
203
|
},
|
|
205
204
|
"scripts": {
|
|
206
|
-
"build": "
|
|
205
|
+
"build": "premove dist && rollup -c",
|
|
207
206
|
"dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" rollup -c --watch -m inline"
|
|
208
207
|
}
|
|
209
208
|
}
|