vitest 0.0.119 → 0.0.120
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/cli.js +2 -2
- package/dist/entry.js +6 -6
- package/dist/{global-8f03a13e.js → global-9532b920.js} +3 -3
- package/dist/{index-478354a1.js → index-df5396e4.js} +10 -10
- package/dist/{index-31a38185.js → index-ea959009.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/{jest-mock-4a754991.js → jest-mock-038a01b3.js} +1 -1
- package/dist/node.js +1 -1
- package/dist/{setup-638014f2.js → setup-c9c7cb5b.js} +1 -1
- package/dist/{vi-092f86e3.js → vi-67a5a3b3.js} +16 -10
- package/dist/worker.js +20 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { m as mergeStream, g as getStream, c as crossSpawn } from './index-6e709
|
|
|
8
8
|
import require$$0, { constants } from 'os';
|
|
9
9
|
import { s as signalExit } from './index-648e7ab2.js';
|
|
10
10
|
import { e as ensurePackageInstalled } from './index-090545ef.js';
|
|
11
|
-
import { c as createVitest } from './index-
|
|
11
|
+
import { c as createVitest } from './index-df5396e4.js';
|
|
12
12
|
import './_commonjsHelpers-c9e3b764.js';
|
|
13
13
|
import 'fs';
|
|
14
14
|
import 'stream';
|
|
@@ -1700,7 +1700,7 @@ function execa(file, args, options) {
|
|
|
1700
1700
|
return mergePromise(spawned, handlePromiseOnce);
|
|
1701
1701
|
}
|
|
1702
1702
|
|
|
1703
|
-
var version = "0.0.
|
|
1703
|
+
var version = "0.0.120";
|
|
1704
1704
|
|
|
1705
1705
|
const CLOSE_TIMEOUT = 1e3;
|
|
1706
1706
|
const cli = cac("vitest");
|
package/dist/entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs, { promises } from 'fs';
|
|
2
|
-
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-
|
|
2
|
+
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-67a5a3b3.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
@@ -11,7 +11,7 @@ import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDif
|
|
|
11
11
|
import { performance } from 'perf_hooks';
|
|
12
12
|
import { createHash } from 'crypto';
|
|
13
13
|
import { format as format$1 } from 'util';
|
|
14
|
-
import './jest-mock-
|
|
14
|
+
import './jest-mock-038a01b3.js';
|
|
15
15
|
import 'tinyspy';
|
|
16
16
|
import 'url';
|
|
17
17
|
import 'tty';
|
|
@@ -2907,7 +2907,7 @@ class SnapshotState {
|
|
|
2907
2907
|
this._dirty = dirty;
|
|
2908
2908
|
this._inlineSnapshots = [];
|
|
2909
2909
|
this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
|
|
2910
|
-
this._counters =
|
|
2910
|
+
this._counters = new Map();
|
|
2911
2911
|
this._index = 0;
|
|
2912
2912
|
this.expand = options.expand || false;
|
|
2913
2913
|
this.added = 0;
|
|
@@ -2944,7 +2944,7 @@ class SnapshotState {
|
|
|
2944
2944
|
}
|
|
2945
2945
|
clear() {
|
|
2946
2946
|
this._snapshotData = this._initialData;
|
|
2947
|
-
this._counters =
|
|
2947
|
+
this._counters = new Map();
|
|
2948
2948
|
this._index = 0;
|
|
2949
2949
|
this.added = 0;
|
|
2950
2950
|
this.matched = 0;
|
|
@@ -3532,7 +3532,7 @@ async function setupGlobalEnv(config) {
|
|
|
3532
3532
|
setupConsoleLogSpy();
|
|
3533
3533
|
await setupChai();
|
|
3534
3534
|
if (config.global)
|
|
3535
|
-
(await import('./global-
|
|
3535
|
+
(await import('./global-9532b920.js')).registerApiGlobally();
|
|
3536
3536
|
}
|
|
3537
3537
|
function setupConsoleLogSpy() {
|
|
3538
3538
|
const stdout = new Writable({
|
|
@@ -3580,7 +3580,7 @@ async function runSetupFiles(config) {
|
|
|
3580
3580
|
}));
|
|
3581
3581
|
}
|
|
3582
3582
|
|
|
3583
|
-
function serializeError(val, seen =
|
|
3583
|
+
function serializeError(val, seen = new WeakSet()) {
|
|
3584
3584
|
if (!val || typeof val === "string")
|
|
3585
3585
|
return val;
|
|
3586
3586
|
if (typeof val === "function")
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { g as globalApis } from './constants-22bbd600.js';
|
|
2
|
-
import { i as index } from './index-
|
|
2
|
+
import { i as index } from './index-ea959009.js';
|
|
3
3
|
import 'url';
|
|
4
4
|
import './index-090545ef.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './vi-
|
|
8
|
+
import './vi-67a5a3b3.js';
|
|
9
9
|
import './_commonjsHelpers-c9e3b764.js';
|
|
10
|
-
import './jest-mock-
|
|
10
|
+
import './jest-mock-038a01b3.js';
|
|
11
11
|
import 'chai';
|
|
12
12
|
import 'tinyspy';
|
|
13
13
|
|
|
@@ -6847,7 +6847,7 @@ const MocksPlugin = () => {
|
|
|
6847
6847
|
};
|
|
6848
6848
|
};
|
|
6849
6849
|
|
|
6850
|
-
const spinnerMap =
|
|
6850
|
+
const spinnerMap = new WeakMap();
|
|
6851
6851
|
const pointer = c.yellow(F_POINTER);
|
|
6852
6852
|
const skipped = c.dim(c.gray(F_DOWN));
|
|
6853
6853
|
function getCols(delta = 0) {
|
|
@@ -7598,7 +7598,7 @@ createLogUpdate(process$1.stderr);
|
|
|
7598
7598
|
|
|
7599
7599
|
const DURATION_LONG = 300;
|
|
7600
7600
|
const MAX_HEIGHT = 20;
|
|
7601
|
-
const outputMap =
|
|
7601
|
+
const outputMap = new WeakMap();
|
|
7602
7602
|
function formatFilepath(path) {
|
|
7603
7603
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
7604
7604
|
const basename = path.slice(lastSlash);
|
|
@@ -7893,9 +7893,9 @@ async function reportCoverage(ctx) {
|
|
|
7893
7893
|
|
|
7894
7894
|
class StateManager {
|
|
7895
7895
|
constructor() {
|
|
7896
|
-
this.filesMap =
|
|
7897
|
-
this.idMap =
|
|
7898
|
-
this.taskFileMap =
|
|
7896
|
+
this.filesMap = new Map();
|
|
7897
|
+
this.idMap = new Map();
|
|
7898
|
+
this.taskFileMap = new WeakMap();
|
|
7899
7899
|
}
|
|
7900
7900
|
getFiles(keys) {
|
|
7901
7901
|
if (keys)
|
|
@@ -7983,7 +7983,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
7983
7983
|
return resolved;
|
|
7984
7984
|
}
|
|
7985
7985
|
|
|
7986
|
-
const promiseMap =
|
|
7986
|
+
const promiseMap = new Map();
|
|
7987
7987
|
async function transformRequest(ctx, id) {
|
|
7988
7988
|
if (!promiseMap.has(id)) {
|
|
7989
7989
|
promiseMap.set(id, _transformRequest(ctx, id).then((r) => {
|
|
@@ -8145,9 +8145,9 @@ class Vitest {
|
|
|
8145
8145
|
this.reporters = void 0;
|
|
8146
8146
|
this.outputStream = process.stdout;
|
|
8147
8147
|
this.errorStream = process.stderr;
|
|
8148
|
-
this.invalidates =
|
|
8149
|
-
this.changedTests =
|
|
8150
|
-
this.visitedFilesMap =
|
|
8148
|
+
this.invalidates = new Set();
|
|
8149
|
+
this.changedTests = new Set();
|
|
8150
|
+
this.visitedFilesMap = new Map();
|
|
8151
8151
|
this.isFirstRun = true;
|
|
8152
8152
|
this.restartsCount = 0;
|
|
8153
8153
|
this._onRestartListeners = [];
|
|
@@ -8357,7 +8357,7 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8357
8357
|
await ctx.setServer(options, server2);
|
|
8358
8358
|
haveStarted = true;
|
|
8359
8359
|
if (options.api)
|
|
8360
|
-
(await import('./setup-
|
|
8360
|
+
(await import('./setup-c9c7cb5b.js')).setup(ctx);
|
|
8361
8361
|
}
|
|
8362
8362
|
},
|
|
8363
8363
|
MocksPlugin()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-67a5a3b3.js';
|
|
2
2
|
import chai, { assert, should } from 'chai';
|
|
3
|
-
import { s as spies, a as spyOn, f as fn } from './jest-mock-
|
|
3
|
+
import { s as spies, a as spyOn, f as fn } from './jest-mock-038a01b3.js';
|
|
4
4
|
|
|
5
5
|
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
6
6
|
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-
|
|
3
|
-
export { f as fn, s as spies, a as spyOn } from './jest-mock-
|
|
1
|
+
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-67a5a3b3.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-ea959009.js';
|
|
3
|
+
export { f as fn, s as spies, a as spyOn } from './jest-mock-038a01b3.js';
|
|
4
4
|
export { assert, default as chai, should } from 'chai';
|
|
5
5
|
import './index-090545ef.js';
|
|
6
6
|
import 'url';
|
package/dist/node.js
CHANGED
|
@@ -4248,7 +4248,7 @@ function abortHandshake(socket, code, message, headers) {
|
|
|
4248
4248
|
function setup(ctx) {
|
|
4249
4249
|
var _a;
|
|
4250
4250
|
const wss = new websocketServer({ noServer: true });
|
|
4251
|
-
const clients =
|
|
4251
|
+
const clients = new Map();
|
|
4252
4252
|
(_a = ctx.server.httpServer) == null ? void 0 : _a.on("upgrade", (request, socket, head) => {
|
|
4253
4253
|
if (!request.url)
|
|
4254
4254
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as noop, i as isObject } from './index-090545ef.js';
|
|
2
2
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-c9e3b764.js';
|
|
3
|
-
import { a as spyOn, f as fn, s as spies } from './jest-mock-
|
|
3
|
+
import { a as spyOn, f as fn, s as spies } from './jest-mock-038a01b3.js';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __defProps = Object.defineProperties;
|
|
@@ -86,8 +86,8 @@ function normalizeTest(fn, timeout) {
|
|
|
86
86
|
return withTimeout(ensureAsyncTest(fn), timeout);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
const fnMap =
|
|
90
|
-
const hooksMap =
|
|
89
|
+
const fnMap = new WeakMap();
|
|
90
|
+
const hooksMap = new WeakMap();
|
|
91
91
|
function setFn(key, fn) {
|
|
92
92
|
fnMap.set(key, fn);
|
|
93
93
|
}
|
|
@@ -206,7 +206,7 @@ function equals(a, b, customTesters, strictCheck) {
|
|
|
206
206
|
function isAsymmetric(obj) {
|
|
207
207
|
return !!obj && isA("Function", obj.asymmetricMatch);
|
|
208
208
|
}
|
|
209
|
-
function hasAsymmetric(obj, seen =
|
|
209
|
+
function hasAsymmetric(obj, seen = new Set()) {
|
|
210
210
|
if (seen.has(obj))
|
|
211
211
|
return false;
|
|
212
212
|
seen.add(obj);
|
|
@@ -410,7 +410,7 @@ const hasPropertyInObject = (object, key) => {
|
|
|
410
410
|
};
|
|
411
411
|
const isObjectWithKeys = (a) => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
|
|
412
412
|
const subsetEquality = (object, subset) => {
|
|
413
|
-
const subsetEqualityWithContext = (seenReferences =
|
|
413
|
+
const subsetEqualityWithContext = (seenReferences = new WeakMap()) => (object2, subset2) => {
|
|
414
414
|
if (!isObjectWithKeys(subset2))
|
|
415
415
|
return void 0;
|
|
416
416
|
return Object.keys(subset2).every((key) => {
|
|
@@ -797,6 +797,12 @@ const originalSetInterval = global.setInterval;
|
|
|
797
797
|
const originalClearTimeout = global.clearTimeout;
|
|
798
798
|
const originalClearInterval = global.clearInterval;
|
|
799
799
|
const MAX_LOOPS = 1e4;
|
|
800
|
+
var QueueTaskType;
|
|
801
|
+
(function(QueueTaskType2) {
|
|
802
|
+
QueueTaskType2["Interval"] = "interval";
|
|
803
|
+
QueueTaskType2["Timeout"] = "timeout";
|
|
804
|
+
QueueTaskType2["Immediate"] = "immediate";
|
|
805
|
+
})(QueueTaskType || (QueueTaskType = {}));
|
|
800
806
|
const assertEvery = (assertions, message) => {
|
|
801
807
|
if (assertions.some((a) => !a))
|
|
802
808
|
throw new Error(message);
|
|
@@ -841,8 +847,8 @@ class FakeTimers {
|
|
|
841
847
|
return resultBuilder(id, cb);
|
|
842
848
|
};
|
|
843
849
|
};
|
|
844
|
-
this._setTimeout = spyOn(global, "setTimeout").mockImplementation(spyFactory(
|
|
845
|
-
this._setInterval = spyOn(global, "setInterval").mockImplementation(spyFactory(
|
|
850
|
+
this._setTimeout = spyOn(global, "setTimeout").mockImplementation(spyFactory(QueueTaskType.Timeout, getNodeTimeout));
|
|
851
|
+
this._setInterval = spyOn(global, "setInterval").mockImplementation(spyFactory(QueueTaskType.Interval, getNodeTimeout));
|
|
846
852
|
const clearTimerFactory = (spyType) => (id) => {
|
|
847
853
|
if (id === void 0)
|
|
848
854
|
return;
|
|
@@ -850,8 +856,8 @@ class FakeTimers {
|
|
|
850
856
|
if (index !== -1)
|
|
851
857
|
this._tasksQueue.splice(index, 1);
|
|
852
858
|
};
|
|
853
|
-
this._clearTimeout = spyOn(global, "clearTimeout").mockImplementation(clearTimerFactory(
|
|
854
|
-
this._clearInterval = spyOn(global, "clearInterval").mockImplementation(clearTimerFactory(
|
|
859
|
+
this._clearTimeout = spyOn(global, "clearTimeout").mockImplementation(clearTimerFactory(QueueTaskType.Timeout));
|
|
860
|
+
this._clearInterval = spyOn(global, "clearInterval").mockImplementation(clearTimerFactory(QueueTaskType.Interval));
|
|
855
861
|
}
|
|
856
862
|
useRealTimers() {
|
|
857
863
|
this._isMocked = false;
|
|
@@ -947,7 +953,7 @@ class FakeTimers {
|
|
|
947
953
|
this._tasksQueue.sort((t1, t2) => {
|
|
948
954
|
const diff = t1.call.nestedMs - t2.call.nestedMs;
|
|
949
955
|
if (diff === 0) {
|
|
950
|
-
if (t1.type ===
|
|
956
|
+
if (t1.type === QueueTaskType.Immediate && t2.type !== QueueTaskType.Immediate)
|
|
951
957
|
return 1;
|
|
952
958
|
return 0;
|
|
953
959
|
}
|
package/dist/worker.js
CHANGED
|
@@ -8,7 +8,7 @@ import path from 'path';
|
|
|
8
8
|
import fs, { promises, realpathSync, statSync, Stats, existsSync, readdirSync } from 'fs';
|
|
9
9
|
import assert from 'assert';
|
|
10
10
|
import { format as format$2, inspect } from 'util';
|
|
11
|
-
import { a as spyOn, s as spies } from './jest-mock-
|
|
11
|
+
import { a as spyOn, s as spies } from './jest-mock-038a01b3.js';
|
|
12
12
|
import { r as rpc } from './rpc-8c7cc374.js';
|
|
13
13
|
import 'tty';
|
|
14
14
|
import 'local-pkg';
|
|
@@ -9327,6 +9327,7 @@ function createMocker(root, mockMap) {
|
|
|
9327
9327
|
|
|
9328
9328
|
const defaultInline = [
|
|
9329
9329
|
"vitest/dist",
|
|
9330
|
+
/vitest-virtual-\w+\/dist/,
|
|
9330
9331
|
/virtual:/,
|
|
9331
9332
|
/\.ts$/,
|
|
9332
9333
|
/\/esm\/.*\.js$/,
|
|
@@ -9351,29 +9352,33 @@ const stubRequests = {
|
|
|
9351
9352
|
}
|
|
9352
9353
|
}
|
|
9353
9354
|
};
|
|
9355
|
+
function hasNestedDefault(target) {
|
|
9356
|
+
return "__esModule" in target && target.__esModule && "default" in target.default;
|
|
9357
|
+
}
|
|
9358
|
+
function proxyMethod(name, isNested) {
|
|
9359
|
+
return function(target, key, ...args) {
|
|
9360
|
+
const result = Reflect[name](target, key, ...args);
|
|
9361
|
+
if (isNested && key === "default" || !result)
|
|
9362
|
+
return Reflect[name](target.default, key, ...args);
|
|
9363
|
+
return result;
|
|
9364
|
+
};
|
|
9365
|
+
}
|
|
9354
9366
|
async function interpretedImport(path, interpretDefault) {
|
|
9355
9367
|
const mod = await import(path);
|
|
9356
9368
|
if (interpretDefault && "default" in mod) {
|
|
9369
|
+
const isNested = hasNestedDefault(mod);
|
|
9357
9370
|
return new Proxy(mod, {
|
|
9358
|
-
get(
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
return Reflect.set(target, key, value, receiver) || Reflect.set(target.default, key, value, receiver);
|
|
9363
|
-
},
|
|
9364
|
-
has(target, key) {
|
|
9365
|
-
return Reflect.has(target, key) || Reflect.has(target.default, key);
|
|
9366
|
-
},
|
|
9367
|
-
deleteProperty(target, key) {
|
|
9368
|
-
return Reflect.deleteProperty(target, key) || Reflect.deleteProperty(target.default, key);
|
|
9369
|
-
}
|
|
9371
|
+
get: proxyMethod("get", isNested),
|
|
9372
|
+
set: proxyMethod("set", isNested),
|
|
9373
|
+
has: proxyMethod("has", isNested),
|
|
9374
|
+
deleteProperty: proxyMethod("deleteProperty", isNested)
|
|
9370
9375
|
});
|
|
9371
9376
|
}
|
|
9372
9377
|
return mod;
|
|
9373
9378
|
}
|
|
9374
9379
|
async function executeInViteNode(options) {
|
|
9375
9380
|
const { moduleCache, root, files, fetch, mockMap } = options;
|
|
9376
|
-
const externalCache =
|
|
9381
|
+
const externalCache = new Map();
|
|
9377
9382
|
builtinModules.forEach((m) => externalCache.set(m, true));
|
|
9378
9383
|
const {
|
|
9379
9384
|
getActualPath,
|
|
@@ -9563,7 +9568,7 @@ function patchWindowsImportPath(path) {
|
|
|
9563
9568
|
}
|
|
9564
9569
|
|
|
9565
9570
|
let _viteNode;
|
|
9566
|
-
const moduleCache =
|
|
9571
|
+
const moduleCache = new Map();
|
|
9567
9572
|
const mockMap = {};
|
|
9568
9573
|
async function startViteNode(ctx) {
|
|
9569
9574
|
if (_viteNode)
|