vitest 0.34.3 → 0.34.5
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/dist/browser.d.ts +28 -2
- package/dist/browser.js +11 -2
- package/dist/child.js +13 -8
- package/dist/{chunk-api-setup.3b016b1c.js → chunk-api-setup.d65b007d.js} +3 -3
- package/dist/{chunk-install-pkg.a036014e.js → chunk-install-pkg.e623b1bf.js} +3 -3
- package/dist/{chunk-integrations-globals.7f4b17bf.js → chunk-integrations-globals.5afac659.js} +2 -2
- package/dist/{chunk-node-git.c410fed8.js → chunk-node-git.36288174.js} +1 -1
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +4 -4
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/entry-vm.js +3 -3
- package/dist/entry.js +6 -3
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +3 -2
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +25 -2
- package/dist/index.js +3 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/{reporters-2ff87305.d.ts → reporters-5f784f42.d.ts} +23 -18
- package/dist/reporters.d.ts +1 -1
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +1 -1
- package/dist/{vendor-environments.8eb4d407.js → vendor-environments.b9b2f624.js} +26 -5
- package/dist/{vendor-execute.a63e187f.js → vendor-execute.07d1a420.js} +10 -3
- package/dist/{vendor-index.9378c9a4.js → vendor-index.3e351f42.js} +2 -0
- package/dist/{vendor-index.7178e7a2.js → vendor-index.7646b3af.js} +1 -1
- package/dist/{vendor-index.1f85e5f1.js → vendor-index.85fc950a.js} +2 -2
- package/dist/{vendor-node.5ce5f335.js → vendor-node.81dd929c.js} +123 -96
- package/dist/{vendor-vi.597d9e06.js → vendor-vi.6873a1c1.js} +149 -22
- package/dist/vm.js +11 -6
- package/dist/worker.js +13 -8
- package/package.json +8 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { pathToFileURL } from 'node:url';
|
|
2
1
|
import { resolve, normalize } from 'pathe';
|
|
3
2
|
import { r as resolvePath } from './vendor-index.0b5b3600.js';
|
|
3
|
+
import { ViteNodeRunner } from 'vite-node/client';
|
|
4
4
|
import { Console } from 'node:console';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
6
|
|
|
@@ -540,7 +540,12 @@ var happy = {
|
|
|
540
540
|
const { Window } = await importModule("happy-dom");
|
|
541
541
|
const win = new Window({
|
|
542
542
|
...happyDOM,
|
|
543
|
-
|
|
543
|
+
console: console && globalThis.console ? globalThis.console : void 0,
|
|
544
|
+
url: happyDOM.url || "http://localhost:3000",
|
|
545
|
+
settings: {
|
|
546
|
+
...happyDOM.settings,
|
|
547
|
+
disableErrorCapturing: true
|
|
548
|
+
}
|
|
544
549
|
});
|
|
545
550
|
win.Buffer = Buffer;
|
|
546
551
|
if (typeof structuredClone !== "undefined" && !win.structuredClone)
|
|
@@ -558,7 +563,12 @@ var happy = {
|
|
|
558
563
|
const { Window, GlobalWindow } = await importModule("happy-dom");
|
|
559
564
|
const win = new (GlobalWindow || Window)({
|
|
560
565
|
...happyDOM,
|
|
561
|
-
|
|
566
|
+
console: console && global.console ? global.console : void 0,
|
|
567
|
+
url: happyDOM.url || "http://localhost:3000",
|
|
568
|
+
settings: {
|
|
569
|
+
...happyDOM.settings,
|
|
570
|
+
disableErrorCapturing: true
|
|
571
|
+
}
|
|
562
572
|
});
|
|
563
573
|
const { keys, originals } = populateGlobal(global, win, { bindFunctions: true });
|
|
564
574
|
return {
|
|
@@ -635,11 +645,22 @@ function getEnvPackageName(env) {
|
|
|
635
645
|
return envPackageNames[env];
|
|
636
646
|
return `vitest-environment-${env}`;
|
|
637
647
|
}
|
|
638
|
-
|
|
648
|
+
const _loaders = /* @__PURE__ */ new Map();
|
|
649
|
+
async function createEnvironmentLoader(options) {
|
|
650
|
+
if (!_loaders.has(options.root)) {
|
|
651
|
+
const loader = new ViteNodeRunner(options);
|
|
652
|
+
await loader.executeId("/@vite/env");
|
|
653
|
+
_loaders.set(options.root, loader);
|
|
654
|
+
}
|
|
655
|
+
return _loaders.get(options.root);
|
|
656
|
+
}
|
|
657
|
+
async function loadEnvironment(name, options) {
|
|
639
658
|
if (isBuiltinEnvironment(name))
|
|
640
659
|
return environments[name];
|
|
660
|
+
const loader = await createEnvironmentLoader(options);
|
|
661
|
+
const root = loader.root;
|
|
641
662
|
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : await resolvePath(`vitest-environment-${name}`, { url: [root] }) ?? resolve(root, name);
|
|
642
|
-
const pkg = await
|
|
663
|
+
const pkg = await loader.executeId(normalize(packageId));
|
|
643
664
|
if (!pkg || !pkg.default || typeof pkg.default !== "object") {
|
|
644
665
|
throw new TypeError(
|
|
645
666
|
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`
|
|
@@ -337,6 +337,7 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
const _require = createRequire(import.meta.url);
|
|
340
|
+
const requiresCache = /* @__PURE__ */ new WeakMap();
|
|
340
341
|
class CommonjsExecutor {
|
|
341
342
|
context;
|
|
342
343
|
requireCache = /* @__PURE__ */ new Map();
|
|
@@ -354,7 +355,6 @@ class CommonjsExecutor {
|
|
|
354
355
|
this.Module = class Module$1 {
|
|
355
356
|
exports;
|
|
356
357
|
isPreloading = false;
|
|
357
|
-
require;
|
|
358
358
|
id;
|
|
359
359
|
filename;
|
|
360
360
|
loaded;
|
|
@@ -362,15 +362,22 @@ class CommonjsExecutor {
|
|
|
362
362
|
children = [];
|
|
363
363
|
path;
|
|
364
364
|
paths = [];
|
|
365
|
-
constructor(id, parent) {
|
|
365
|
+
constructor(id = "", parent) {
|
|
366
366
|
this.exports = primitives.Object.create(Object.prototype);
|
|
367
|
-
this.require = Module$1.createRequire(id);
|
|
368
367
|
this.path = dirname(id);
|
|
369
368
|
this.id = id;
|
|
370
369
|
this.filename = id;
|
|
371
370
|
this.loaded = false;
|
|
372
371
|
this.parent = parent;
|
|
373
372
|
}
|
|
373
|
+
get require() {
|
|
374
|
+
const require = requiresCache.get(this);
|
|
375
|
+
if (require)
|
|
376
|
+
return require;
|
|
377
|
+
const _require2 = Module$1.createRequire(this.id);
|
|
378
|
+
requiresCache.set(this, _require2);
|
|
379
|
+
return _require2;
|
|
380
|
+
}
|
|
374
381
|
_compile(code, filename) {
|
|
375
382
|
const cjsModule = Module$1.wrap(code);
|
|
376
383
|
const script = new vm.Script(cjsModule, {
|
|
@@ -5,6 +5,7 @@ import { d as distDir } from './vendor-paths.84fc7a99.js';
|
|
|
5
5
|
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
6
6
|
import { a as rpc } from './vendor-rpc.cbd8e972.js';
|
|
7
7
|
import { t as takeCoverageInsideWorker } from './vendor-coverage.78040316.js';
|
|
8
|
+
import { loadDiffConfig } from './browser.js';
|
|
8
9
|
|
|
9
10
|
function setupChaiConfig(config) {
|
|
10
11
|
Object.assign(chai.config, config);
|
|
@@ -46,6 +47,7 @@ async function resolveTestRunner(config, executor) {
|
|
|
46
47
|
testRunner.config = config;
|
|
47
48
|
if (!testRunner.importFile)
|
|
48
49
|
throw new Error('Runner must implement "importFile" method.');
|
|
50
|
+
testRunner.config.diffOptions = await loadDiffConfig(config, executor);
|
|
49
51
|
const originalOnTaskUpdate = testRunner.onTaskUpdate;
|
|
50
52
|
testRunner.onTaskUpdate = async (task) => {
|
|
51
53
|
const p = rpc().onTaskUpdate(task);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
|
-
import { e as bench, c as createExpect, d as globalExpect, v as vi, f as vitest } from './vendor-vi.
|
|
2
|
+
import { e as bench, c as createExpect, d as globalExpect, v as vi, f as vitest } from './vendor-vi.6873a1c1.js';
|
|
3
3
|
import { i as isFirstRun, r as runOnce } from './vendor-run-once.3e5ef7d7.js';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
import { assert, should } from 'chai';
|
|
@@ -7,7 +7,7 @@ import require$$0$1 from 'child_process';
|
|
|
7
7
|
import f from 'path';
|
|
8
8
|
import $ from 'fs';
|
|
9
9
|
import url from 'node:url';
|
|
10
|
-
import
|
|
10
|
+
import nodeos__default, { constants } from 'node:os';
|
|
11
11
|
import require$$0 from 'assert';
|
|
12
12
|
import require$$2 from 'events';
|
|
13
13
|
import { createWriteStream, createReadStream } from 'node:fs';
|
|
@@ -1626,7 +1626,7 @@ const setKillTimeout = (kill, signal, options, killResult) => {
|
|
|
1626
1626
|
|
|
1627
1627
|
const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
|
|
1628
1628
|
|
|
1629
|
-
const isSigterm = signal => signal ===
|
|
1629
|
+
const isSigterm = signal => signal === nodeos__default.constants.signals.SIGTERM
|
|
1630
1630
|
|| (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
|
|
1631
1631
|
|
|
1632
1632
|
const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
|