vitest 5.1.0-beta.1 → 5.1.1
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 +8 -6
- package/dist/browser.js +10 -10
- package/dist/chunks/{base.PJyN9N0u.js → base.C2su7_N0.js} +16 -21
- package/dist/chunks/{browser.d.D7a15z82.d.ts → browser.d.B-QwH_F6.d.ts} +3 -3
- package/dist/chunks/{cac.Ccf5Je_F.js → cac.BK306qhQ.js} +29 -22
- package/dist/chunks/{cli-api.DE22LIzq.js → cli-api.D6E8EtSi.js} +990 -166
- package/dist/chunks/{config.d.BgktgHfG.d.ts → config.d.BpJq6tRA.d.ts} +43 -2
- package/dist/chunks/{console.DrMPSuFo.js → console.VJUxd1rM.js} +3 -3
- package/dist/chunks/{coverage.-bm5IxnW.js → coverage.9iqXE2gN.js} +1 -1
- package/dist/chunks/{coverage.cTDc4uSS.js → coverage.jGCktcGP.js} +1 -1
- package/dist/chunks/{creator.BQ3onxbh.js → creator.CoOCr85O.js} +17 -15
- package/dist/chunks/{display.BlTmubjj.js → display.Cj2h2zsY.js} +1 -1
- package/dist/chunks/{doctor.CPlMs7-y.js → doctor.SRjZIZuA.js} +2 -2
- package/dist/chunks/{environment.d.CbTLsZSj.d.ts → environment.d.rlpAM-ON.d.ts} +1 -1
- package/dist/chunks/{globals.TipXUFcZ.js → globals.Mxora3_v.js} +11 -10
- package/dist/chunks/{index.BFXLpwll.js → index.C7Nn66Gy.js} +79 -41
- package/dist/chunks/{index.DmDMHCg8.js → index.CAmut2NG.js} +25 -1
- package/dist/chunks/{index.BXttT2gP.js → index.DNcttN5a.js} +288 -437
- package/dist/chunks/{index.B03wg4V0.js → index.Da_szXbS.js} +5 -5
- package/dist/chunks/{index.D14IAvnE.js → index.ER9afepi.js} +269 -141
- package/dist/chunks/{index.D0heQG4v.js → index.Or9psEGe.js} +1 -1
- package/dist/chunks/{init-forks.BL1E3__4.js → init-forks.q4IoGYZe.js} +7 -1
- package/dist/chunks/{init-threads.CYXAGzKQ.js → init-threads.Bf1Frg9S.js} +1 -1
- package/dist/chunks/{init.DVorxUyL.js → init.dGO4K2C0.js} +17 -9
- package/dist/chunks/{inspector.CvyFGlXm.js → inspector.D6o1NPo1.js} +12 -1
- package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
- package/dist/chunks/{modules.BJuCwlRJ.js → moduleSourceMap.Dp1WduWi.js} +31 -1
- package/dist/chunks/{native.cdzHIdmv.js → native.D5q1ylZC.js} +3 -2
- package/dist/chunks/{nativeModuleMocker.3uBcOd84.js → nativeModuleMocker.ihb3q7Cg.js} +6 -4
- package/dist/chunks/{nativeModuleRunner.xi64Afb2.js → nativeModuleRunner.9xPIMzi7.js} +1 -1
- package/dist/chunks/{node.uQulW0ei.js → node.B9mkVmLH.js} +1 -1
- package/dist/chunks/{pathe.M-eThtNZ.Ba-7h1rE.js → pathe.M-eThtNZ.zq3TM4NT.js} +1 -1
- package/dist/chunks/{plugin.d.olEn8IL9.d.ts → plugin.d.Du7hHZwb.d.ts} +115 -41
- package/dist/chunks/{plugins.DPQHVT0p.js → plugins.BPruPOR8.js} +1 -1
- package/dist/chunks/rawSnapshot.DvoRLRNr.js +356 -0
- package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
- package/dist/chunks/{rpc.BV0XpJ5q.js → rpc.CNYWPa97.js} +3 -19
- package/dist/chunks/{rpc.d.DGFP7vWr.d.ts → rpc.d.DHfuwqP0.d.ts} +2 -2
- package/dist/chunks/{run.BfrMbGVD.js → run.zBhXlcZQ.js} +118 -51
- package/dist/chunks/{setup-common.llxJkJaD.js → setup-common.wwc_NYRJ.js} +3 -3
- package/dist/chunks/{source-map.BjWcsIL9.js → source-map.DPHGMWvM.js} +14 -14
- package/dist/chunks/{source-map.d.C5A_Tr6V.d.ts → source-map.d.xB6_75fl.d.ts} +2 -1
- package/dist/chunks/{spy.DDMXghXv.js → spy.BO0hTE3G.js} +76 -53
- package/dist/chunks/{task-utils.d.BUh7ylUT.d.ts → task-utils.d.DgSjIb7r.d.ts} +1 -1
- package/dist/chunks/{utils.DSfl_w8V.js → utils.sAsh2ClK.js} +7 -8
- package/dist/chunks/{vm.Cwj01UFE.js → vm.agn4qnmT.js} +15 -13
- package/dist/chunks/{worker.d.gsA26mmR.d.ts → worker.d.BigfbIsH.d.ts} +3 -3
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +8 -8
- package/dist/index.d.ts +17 -12
- package/dist/index.js +11 -10
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +1 -1
- package/dist/node.d.ts +12 -11
- package/dist/node.js +23 -19
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.js +7 -5
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +7 -3
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +23 -21
- package/dist/workers/forks.js +24 -22
- package/dist/workers/runVmTests.js +20 -17
- package/dist/workers/threads.js +24 -22
- package/dist/workers/vmForks.js +16 -15
- package/dist/workers/vmThreads.js +16 -15
- package/dist/workers/watchdog.js +20 -0
- package/package.json +21 -21
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
// Tests can spy on these globals, and mocks call them internally.
|
|
2
|
+
// `Promise` is not here because zone.js replaces it after Vitest loads.
|
|
3
|
+
const { bind, call } = Function.prototype;
|
|
4
|
+
const uncurryThis = bind.bind(call);
|
|
5
|
+
const ReflectApply = Reflect.apply;
|
|
6
|
+
const ReflectConstruct = Reflect.construct;
|
|
7
|
+
const ReflectDeleteProperty = Reflect.deleteProperty;
|
|
8
|
+
const ReflectOwnKeys = Reflect.ownKeys;
|
|
9
|
+
const ObjectDefineProperty = Object.defineProperty;
|
|
10
|
+
const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
11
|
+
const ObjectGetPrototypeOf = Object.getPrototypeOf;
|
|
12
|
+
const ObjectSetPrototypeOf = Object.setPrototypeOf;
|
|
13
|
+
const WeakRef = globalThis.WeakRef;
|
|
14
|
+
const ArrayPrototypeAt = uncurryThis(Array.prototype.at);
|
|
15
|
+
const ArrayPrototypePush = uncurryThis(Array.prototype.push);
|
|
16
|
+
const ArrayPrototypeShift = uncurryThis(Array.prototype.shift);
|
|
17
|
+
const SetPrototypeAdd = uncurryThis(Set.prototype.add);
|
|
18
|
+
const SetPrototypeClear = uncurryThis(Set.prototype.clear);
|
|
19
|
+
const SetPrototypeDelete = uncurryThis(Set.prototype.delete);
|
|
20
|
+
const SetPrototypeHas = uncurryThis(Set.prototype.has);
|
|
21
|
+
const WeakMapPrototypeGet = uncurryThis(WeakMap.prototype.get);
|
|
22
|
+
const WeakMapPrototypeSet = uncurryThis(WeakMap.prototype.set);
|
|
23
|
+
const WeakRefPrototypeDeref = uncurryThis(WeakRef.prototype.deref);
|
|
24
|
+
const FinalizationRegistryPrototypeRegister = uncurryThis(FinalizationRegistry.prototype.register);
|
|
25
|
+
const StringPrototypeIncludes = uncurryThis(String.prototype.includes);
|
|
26
|
+
|
|
1
27
|
function isMockFunction(fn) {
|
|
2
28
|
return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
|
|
3
29
|
}
|
|
@@ -9,38 +35,36 @@ const DIRTY_MOCK_STATES = /* @__PURE__ */ new Set();
|
|
|
9
35
|
// Mocks whose implementation, once-queue or name changed since their last
|
|
10
36
|
// `mockReset()`, so `resetAllMocks()` only visits mocks that are not already reset
|
|
11
37
|
const DIRTY_MOCK_CONFIGS = /* @__PURE__ */ new Set();
|
|
12
|
-
// a test may spy on `Set.prototype.add`, and the spy itself marks mocks dirty
|
|
13
|
-
const addToSet = Set.prototype.add;
|
|
14
38
|
const MOCK_REFS = /* @__PURE__ */ new WeakMap();
|
|
15
39
|
const MOCK_FINALIZER = new FinalizationRegistry((ref) => {
|
|
16
|
-
DIRTY_MOCK_STATES
|
|
17
|
-
DIRTY_MOCK_CONFIGS
|
|
40
|
+
SetPrototypeDelete(DIRTY_MOCK_STATES, ref);
|
|
41
|
+
SetPrototypeDelete(DIRTY_MOCK_CONFIGS, ref);
|
|
18
42
|
});
|
|
19
43
|
const MOCK_CONFIGS = /* @__PURE__ */ new WeakMap();
|
|
20
44
|
const MOCKS_BY_STATE = /* @__PURE__ */ new WeakMap();
|
|
21
45
|
function markDirty(set, mock) {
|
|
22
|
-
let ref = MOCK_REFS
|
|
46
|
+
let ref = WeakMapPrototypeGet(MOCK_REFS, mock);
|
|
23
47
|
if (!ref) {
|
|
24
48
|
ref = new WeakRef(mock);
|
|
25
|
-
MOCK_REFS
|
|
26
|
-
MOCK_FINALIZER
|
|
49
|
+
WeakMapPrototypeSet(MOCK_REFS, mock, ref);
|
|
50
|
+
FinalizationRegistryPrototypeRegister(MOCK_FINALIZER, mock, ref);
|
|
27
51
|
}
|
|
28
|
-
|
|
52
|
+
SetPrototypeAdd(set, ref);
|
|
29
53
|
}
|
|
30
54
|
function unmarkDirty(set, mock) {
|
|
31
|
-
const ref = MOCK_REFS
|
|
32
|
-
if (ref) set
|
|
55
|
+
const ref = WeakMapPrototypeGet(MOCK_REFS, mock);
|
|
56
|
+
if (ref) SetPrototypeDelete(set, ref);
|
|
33
57
|
}
|
|
34
58
|
function forEachDirty(set, fn) {
|
|
35
59
|
for (const ref of set) {
|
|
36
|
-
const mock = ref
|
|
60
|
+
const mock = WeakRefPrototypeDeref(ref);
|
|
37
61
|
if (mock) fn(mock);
|
|
38
|
-
else set
|
|
62
|
+
else SetPrototypeDelete(set, ref);
|
|
39
63
|
}
|
|
40
64
|
}
|
|
41
65
|
function createMockInstance(options = {}) {
|
|
42
66
|
const { originalImplementation, restore, mockImplementation, resetToMockImplementation, resetToMockName } = options;
|
|
43
|
-
if (restore) MOCK_RESTORE
|
|
67
|
+
if (restore) SetPrototypeAdd(MOCK_RESTORE, restore);
|
|
44
68
|
const config = getDefaultConfig(originalImplementation);
|
|
45
69
|
const state = getDefaultState();
|
|
46
70
|
const mock = createMock({
|
|
@@ -49,7 +73,7 @@ function createMockInstance(options = {}) {
|
|
|
49
73
|
...options
|
|
50
74
|
});
|
|
51
75
|
const mockLength = (mockImplementation || originalImplementation)?.length ?? 0;
|
|
52
|
-
|
|
76
|
+
ObjectDefineProperty(mock, "length", {
|
|
53
77
|
writable: true,
|
|
54
78
|
enumerable: false,
|
|
55
79
|
value: mockLength,
|
|
@@ -59,8 +83,8 @@ function createMockInstance(options = {}) {
|
|
|
59
83
|
// this is used by `vi.spyOn()` for better debugging.
|
|
60
84
|
// when `vi.fn()` is called, we just use the default string
|
|
61
85
|
if (resetToMockName) config.mockName = mock.name || "vi.fn()";
|
|
62
|
-
MOCK_CONFIGS
|
|
63
|
-
MOCKS_BY_STATE
|
|
86
|
+
WeakMapPrototypeSet(MOCK_CONFIGS, mock, config);
|
|
87
|
+
WeakMapPrototypeSet(MOCKS_BY_STATE, state, mock);
|
|
64
88
|
mock._isMockFunction = true;
|
|
65
89
|
mock.getMockImplementation = () => {
|
|
66
90
|
// Jest only returns `config.mockImplementation` here,
|
|
@@ -74,7 +98,7 @@ function createMockInstance(options = {}) {
|
|
|
74
98
|
const updateMockPrototype = () => {
|
|
75
99
|
if (!options.prototypeMembers?.length) reparentMockPrototype(mock, config.onceMockImplementations[0] || config.mockImplementation || originalImplementation);
|
|
76
100
|
};
|
|
77
|
-
|
|
101
|
+
ObjectDefineProperty(mock, "mock", {
|
|
78
102
|
configurable: false,
|
|
79
103
|
enumerable: true,
|
|
80
104
|
writable: false,
|
|
@@ -88,7 +112,7 @@ function createMockInstance(options = {}) {
|
|
|
88
112
|
};
|
|
89
113
|
mock.mockImplementationOnce = function mockImplementationOnce(implementation) {
|
|
90
114
|
markDirty(DIRTY_MOCK_CONFIGS, mock);
|
|
91
|
-
config.onceMockImplementations
|
|
115
|
+
ArrayPrototypePush(config.onceMockImplementations, implementation);
|
|
92
116
|
updateMockPrototype();
|
|
93
117
|
return mock;
|
|
94
118
|
};
|
|
@@ -254,13 +278,13 @@ function spyOn(object, key, accessor) {
|
|
|
254
278
|
};
|
|
255
279
|
if (accessType !== "value") delete desc.writable;
|
|
256
280
|
desc[accessType] = cb;
|
|
257
|
-
|
|
281
|
+
ObjectDefineProperty(object, key, desc);
|
|
258
282
|
};
|
|
259
283
|
const restore = () => {
|
|
260
284
|
// if method is defined on the prototype, we can just remove it from
|
|
261
285
|
// the current object instead of redefining a copy of it
|
|
262
|
-
if (originalDescriptorObject !== object)
|
|
263
|
-
else if (originalDescriptor && !original)
|
|
286
|
+
if (originalDescriptorObject !== object) ReflectDeleteProperty(object, key);
|
|
287
|
+
else if (originalDescriptor && !original) ObjectDefineProperty(object, key, originalDescriptor);
|
|
264
288
|
else reassign(original);
|
|
265
289
|
};
|
|
266
290
|
const mock = createMockInstance({
|
|
@@ -271,19 +295,19 @@ function spyOn(object, key, accessor) {
|
|
|
271
295
|
try {
|
|
272
296
|
reassign(ssr ? () => mock : mock);
|
|
273
297
|
} catch (error) {
|
|
274
|
-
if (error instanceof TypeError && Symbol.toStringTag && object[Symbol.toStringTag] === "Module" && (error.message
|
|
298
|
+
if (error instanceof TypeError && Symbol.toStringTag && object[Symbol.toStringTag] === "Module" && (StringPrototypeIncludes(error.message, "Cannot redefine property") || StringPrototypeIncludes(error.message, "Cannot replace module namespace") || StringPrototypeIncludes(error.message, "can't redefine non-configurable property"))) throw new TypeError(`Cannot spy on export "${String(key)}". Module namespace is not configurable in ESM. See: https://vitest.dev/guide/mocking/modules#mocking-a-module`, { cause: error });
|
|
275
299
|
throw error;
|
|
276
300
|
}
|
|
277
301
|
return mock;
|
|
278
302
|
}
|
|
279
303
|
function getDescriptor(obj, method) {
|
|
280
|
-
const objDescriptor =
|
|
304
|
+
const objDescriptor = ObjectGetOwnPropertyDescriptor(obj, method);
|
|
281
305
|
if (objDescriptor) return [obj, objDescriptor];
|
|
282
|
-
let currentProto =
|
|
306
|
+
let currentProto = ObjectGetPrototypeOf(obj);
|
|
283
307
|
while (currentProto !== null) {
|
|
284
|
-
const descriptor =
|
|
308
|
+
const descriptor = ObjectGetOwnPropertyDescriptor(currentProto, method);
|
|
285
309
|
if (descriptor) return [currentProto, descriptor];
|
|
286
|
-
currentProto =
|
|
310
|
+
currentProto = ObjectGetPrototypeOf(currentProto);
|
|
287
311
|
}
|
|
288
312
|
}
|
|
289
313
|
function assert(condition, message) {
|
|
@@ -295,7 +319,7 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
|
|
|
295
319
|
const pseudoOriginal = mockImplementation;
|
|
296
320
|
const name = mockName || original?.name || "Mock";
|
|
297
321
|
const noopImplementation = function() {};
|
|
298
|
-
const prototypeMock = prototypeState && MOCKS_BY_STATE
|
|
322
|
+
const prototypeMock = prototypeState && WeakMapPrototypeGet(MOCKS_BY_STATE, prototypeState);
|
|
299
323
|
const namedObject = {
|
|
300
324
|
// to keep the name of the function intact
|
|
301
325
|
[name]: function(...args) {
|
|
@@ -316,7 +340,7 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
|
|
|
316
340
|
const context = new.target ? void 0 : this;
|
|
317
341
|
const [instanceIndex, instancePrototypeIndex] = registerInstance(context, state, prototypeState);
|
|
318
342
|
const [contextIndex, contextPrototypeIndex] = registerContext(context, state, prototypeState);
|
|
319
|
-
const implementation = config.onceMockImplementations
|
|
343
|
+
const implementation = ArrayPrototypeShift(config.onceMockImplementations) || config.mockImplementation || prototypeConfig && ArrayPrototypeShift(prototypeConfig.onceMockImplementations) || prototypeConfig?.mockImplementation || original || noopImplementation;
|
|
320
344
|
let returnValue;
|
|
321
345
|
let thrownValue;
|
|
322
346
|
let didThrow = false;
|
|
@@ -330,7 +354,7 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
|
|
|
330
354
|
mock,
|
|
331
355
|
implementation === noopImplementation ? void 0 : implementation
|
|
332
356
|
);
|
|
333
|
-
returnValue =
|
|
357
|
+
returnValue = ReflectConstruct(implementation, args, new.target);
|
|
334
358
|
// jest calls this before the implementation, but we have to resolve this _after_
|
|
335
359
|
// because we cannot do it before the `Reflect.construct` called the custom implementation.
|
|
336
360
|
// fortunately, the constructor is always an empty function because `prototypeMethods`
|
|
@@ -342,7 +366,7 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
|
|
|
342
366
|
if (prototypeMock !== mock.prototype[prop]) continue;
|
|
343
367
|
const isMock = isMockFunction(prototypeMock);
|
|
344
368
|
const prototypeState = isMock ? prototypeMock.mock : void 0;
|
|
345
|
-
const prototypeConfig = isMock ? MOCK_CONFIGS
|
|
369
|
+
const prototypeConfig = isMock ? WeakMapPrototypeGet(MOCK_CONFIGS, prototypeMock) : void 0;
|
|
346
370
|
returnValue[prop] = createMockInstance({
|
|
347
371
|
originalImplementation: keepMembersImplementation ? prototypeConfig?.mockOriginal : void 0,
|
|
348
372
|
prototypeState,
|
|
@@ -350,11 +374,11 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
|
|
|
350
374
|
keepMembersImplementation
|
|
351
375
|
});
|
|
352
376
|
}
|
|
353
|
-
} else returnValue = implementation
|
|
377
|
+
} else returnValue = ReflectApply(implementation, this, args);
|
|
354
378
|
} catch (error) {
|
|
355
379
|
thrownValue = error;
|
|
356
380
|
didThrow = true;
|
|
357
|
-
if (error instanceof TypeError && error.message
|
|
381
|
+
if (error instanceof TypeError && StringPrototypeIncludes(error.message, "is not a constructor")) console.warn(`[vitest] The ${namedObject[name].getMockName()} mock did not use 'function' or 'class' in its implementation, see https://vitest.dev/api/vi#vi-spyon for examples.`);
|
|
358
382
|
throw error;
|
|
359
383
|
} finally {
|
|
360
384
|
if (didThrow) {
|
|
@@ -401,36 +425,36 @@ function reparentMockPrototype(mock, implementation) {
|
|
|
401
425
|
// function) reverts the chain to `Object.prototype`, the parent every mock
|
|
402
426
|
// is created with
|
|
403
427
|
const parent = implementation?.prototype ?? Object.prototype;
|
|
404
|
-
if (mockPrototype !== parent &&
|
|
428
|
+
if (mockPrototype !== parent && ObjectGetPrototypeOf(mockPrototype) !== parent) ObjectSetPrototypeOf(mockPrototype, parent);
|
|
405
429
|
}
|
|
406
430
|
function registerCalls(args, state, prototypeState) {
|
|
407
|
-
state.calls
|
|
408
|
-
prototypeState
|
|
431
|
+
ArrayPrototypePush(state.calls, args);
|
|
432
|
+
if (prototypeState) ArrayPrototypePush(prototypeState.calls, args);
|
|
409
433
|
}
|
|
410
434
|
function registerInvocationOrder(order, state, prototypeState) {
|
|
411
|
-
state.invocationCallOrder
|
|
412
|
-
prototypeState
|
|
435
|
+
ArrayPrototypePush(state.invocationCallOrder, order);
|
|
436
|
+
if (prototypeState) ArrayPrototypePush(prototypeState.invocationCallOrder, order);
|
|
413
437
|
}
|
|
414
438
|
function registerResult(result, state, prototypeState) {
|
|
415
|
-
state.results
|
|
416
|
-
prototypeState
|
|
439
|
+
ArrayPrototypePush(state.results, result);
|
|
440
|
+
if (prototypeState) ArrayPrototypePush(prototypeState.results, result);
|
|
417
441
|
}
|
|
418
442
|
function registerSettledResult(result, state, prototypeState) {
|
|
419
|
-
state.settledResults
|
|
420
|
-
prototypeState
|
|
443
|
+
ArrayPrototypePush(state.settledResults, result);
|
|
444
|
+
if (prototypeState) ArrayPrototypePush(prototypeState.settledResults, result);
|
|
421
445
|
}
|
|
422
446
|
function registerInstance(instance, state, prototypeState) {
|
|
423
|
-
return [state.instances
|
|
447
|
+
return [ArrayPrototypePush(state.instances, instance), prototypeState && ArrayPrototypePush(prototypeState.instances, instance)];
|
|
424
448
|
}
|
|
425
449
|
function registerContext(context, state, prototypeState) {
|
|
426
|
-
return [state.contexts
|
|
450
|
+
return [ArrayPrototypePush(state.contexts, context), prototypeState && ArrayPrototypePush(prototypeState.contexts, context)];
|
|
427
451
|
}
|
|
428
452
|
function copyOriginalStaticProperties(mock, original) {
|
|
429
453
|
const { properties, descriptors } = getAllProperties(original);
|
|
430
454
|
for (const key of properties) {
|
|
431
455
|
const descriptor = descriptors[key];
|
|
432
456
|
if (getDescriptor(mock, key)) continue;
|
|
433
|
-
|
|
457
|
+
ObjectDefineProperty(mock, key, descriptor);
|
|
434
458
|
}
|
|
435
459
|
}
|
|
436
460
|
const ignoreProperties = /* @__PURE__ */ new Set([
|
|
@@ -440,16 +464,15 @@ const ignoreProperties = /* @__PURE__ */ new Set([
|
|
|
440
464
|
Symbol.for("nodejs.util.promisify.custom")
|
|
441
465
|
]);
|
|
442
466
|
function getAllProperties(original) {
|
|
443
|
-
const properties =
|
|
467
|
+
const properties = [];
|
|
444
468
|
const descriptors = {};
|
|
445
469
|
while (original && original !== Object.prototype && original !== Function.prototype) {
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
descriptors[prop] = Object.getOwnPropertyDescriptor(original, prop);
|
|
470
|
+
for (const prop of ReflectOwnKeys(original)) {
|
|
471
|
+
if (descriptors[prop] || SetPrototypeHas(ignoreProperties, prop)) continue;
|
|
472
|
+
ArrayPrototypePush(properties, prop);
|
|
473
|
+
descriptors[prop] = ObjectGetOwnPropertyDescriptor(original, prop);
|
|
451
474
|
}
|
|
452
|
-
original =
|
|
475
|
+
original = ObjectGetPrototypeOf(original);
|
|
453
476
|
}
|
|
454
477
|
return {
|
|
455
478
|
properties,
|
|
@@ -473,14 +496,14 @@ function getDefaultState() {
|
|
|
473
496
|
settledResults: [],
|
|
474
497
|
results: [],
|
|
475
498
|
get lastCall() {
|
|
476
|
-
return state.calls
|
|
499
|
+
return ArrayPrototypeAt(state.calls, -1);
|
|
477
500
|
}
|
|
478
501
|
};
|
|
479
502
|
return state;
|
|
480
503
|
}
|
|
481
504
|
function restoreAllMocks() {
|
|
482
505
|
for (const restore of MOCK_RESTORE) restore();
|
|
483
|
-
MOCK_RESTORE
|
|
506
|
+
SetPrototypeClear(MOCK_RESTORE);
|
|
484
507
|
}
|
|
485
508
|
function clearAllMocks() {
|
|
486
509
|
forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockClear());
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="chai" />
|
|
2
|
-
import {
|
|
2
|
+
import { bq as SnapshotState, n as Test, br as PromisifyAssertion, bs as Tester, bt as Plugin, ae as BenchResult, a as File } from './config.d.BpJq6tRA.js';
|
|
3
3
|
|
|
4
4
|
interface SnapshotMatcher<
|
|
5
5
|
R extends void | Promise<void>,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { stripVTControlCharacters } from 'node:util';
|
|
2
|
-
import { t as truncateString$1 } from './display.
|
|
3
|
-
import { i as isAbsolute, a as relative, d as dirname, b as basename, s as slash } from './pathe.M-eThtNZ.
|
|
2
|
+
import { t as truncateString$1 } from './display.Cj2h2zsY.js';
|
|
3
|
+
import { i as isAbsolute, a as relative, d as dirname, b as basename, s as slash } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
4
4
|
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
5
5
|
|
|
6
6
|
const F_RIGHT = "→";
|
|
@@ -87,9 +87,6 @@ function renderSnapshotSummary(rootDir, snapshots) {
|
|
|
87
87
|
}
|
|
88
88
|
return summary;
|
|
89
89
|
}
|
|
90
|
-
function countTestErrors(tasks) {
|
|
91
|
-
return tasks.reduce((c, i) => c + (i.result?.errors?.length || 0), 0);
|
|
92
|
-
}
|
|
93
90
|
function getStateString(tasks, name = "tests", showTotal = true) {
|
|
94
91
|
if (tasks.length === 0) return $.dim(`no ${name}`);
|
|
95
92
|
const passed = tasks.reduce((acc, i) => {
|
|
@@ -149,7 +146,9 @@ function padSummaryTitle(str) {
|
|
|
149
146
|
return $.dim(`${str.padStart(11)} `);
|
|
150
147
|
}
|
|
151
148
|
function truncateString(text, maxLength) {
|
|
152
|
-
|
|
149
|
+
const plainText = stripVTControlCharacters(text);
|
|
150
|
+
if (plainText.length <= maxLength) return text;
|
|
151
|
+
return truncateString$1(plainText, maxLength);
|
|
153
152
|
}
|
|
154
153
|
function capitalize(text) {
|
|
155
154
|
return `${text[0].toUpperCase()}${text.slice(1)}`;
|
|
@@ -164,12 +163,12 @@ function noun(count, singular, plural) {
|
|
|
164
163
|
|
|
165
164
|
var utils = /*#__PURE__*/Object.freeze({
|
|
166
165
|
__proto__: null,
|
|
167
|
-
countTestErrors: countTestErrors,
|
|
168
166
|
divider: divider,
|
|
169
167
|
errorBanner: errorBanner,
|
|
170
168
|
formatProjectName: formatProjectName,
|
|
171
169
|
formatTime: formatTime,
|
|
172
170
|
formatTimeString: formatTimeString,
|
|
171
|
+
getCols: getCols,
|
|
173
172
|
getStateString: getStateString,
|
|
174
173
|
getStateSymbol: getStateSymbol,
|
|
175
174
|
noun: noun,
|
|
@@ -181,4 +180,4 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
181
180
|
withLabel: withLabel
|
|
182
181
|
});
|
|
183
182
|
|
|
184
|
-
export {
|
|
183
|
+
export { F_TREE_NODE_MIDDLE as F, F_TREE_NODE_END as a, F_CHECK as b, F_POINTER as c, F_DOWN_RIGHT as d, formatProjectName as e, formatTimeString as f, getStateSymbol as g, getStateString as h, formatTime as i, errorBanner as j, divider as k, F_RIGHT as l, getCols as m, noun as n, truncateString as o, padSummaryTitle as p, renderSnapshotSummary as r, separator as s, taskFail as t, utils as u, withLabel as w };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
2
2
|
import v8 from 'node:v8';
|
|
3
3
|
import vm, { isContext, runInContext } from 'node:vm';
|
|
4
|
-
import { l as loadEnvironment, a as listenForErrors, e as emitModuleRunner } from './init.
|
|
4
|
+
import { l as loadEnvironment, a as listenForErrors, e as emitModuleRunner } from './init.dGO4K2C0.js';
|
|
5
5
|
import { distDir } from '../path.js';
|
|
6
|
-
import { createCustomConsole } from './console.
|
|
6
|
+
import { createCustomConsole } from './console.VJUxd1rM.js';
|
|
7
7
|
import fs__default from 'node:fs';
|
|
8
8
|
import { createRequire, Module, isBuiltin } from 'node:module';
|
|
9
|
-
import { d as dirname,
|
|
10
|
-
import { l as lookupPackageScopeType } from './resolver.
|
|
9
|
+
import { d as dirname, k as extname, b as basename, C as CSS_LANGS_RE, l as KNOWN_ASSET_RE, t as toArray, m as splitFileAndPostfix, n as normalize, o as isBareImport, r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
10
|
+
import { l as lookupPackageScopeType } from './resolver.BzpmeQeT.js';
|
|
11
11
|
import { initSync, parse } from 'es-module-lexer';
|
|
12
12
|
import { dirname as dirname$1 } from 'node:path';
|
|
13
|
-
import { V as VITEST_VM_CONTEXT_SYMBOL, s as startVitestModuleRunner, c as createNodeImportMeta } from './index.
|
|
13
|
+
import { V as VITEST_VM_CONTEXT_SYMBOL, s as startVitestModuleRunner, c as createNodeImportMeta } from './index.C7Nn66Gy.js';
|
|
14
14
|
import { getDefaultRequestStubs } from '../module-evaluator.js';
|
|
15
|
-
import { b as setupEnv } from './setup-common.
|
|
15
|
+
import { b as setupEnv } from './setup-common.wwc_NYRJ.js';
|
|
16
16
|
import { p as provideWorkerState } from './utils.DYj33du9.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -344,7 +344,8 @@ class CommonjsExecutor {
|
|
|
344
344
|
}
|
|
345
345
|
requireJs = (m, filename) => {
|
|
346
346
|
const content = this.fs.readFile(filename);
|
|
347
|
-
|
|
347
|
+
const code = content.startsWith("#!") ? `//${content.slice(2)}` : content;
|
|
348
|
+
m._compile(code, filename);
|
|
348
349
|
};
|
|
349
350
|
requireJson = (m, filename) => {
|
|
350
351
|
const code = this.fs.readFile(filename);
|
|
@@ -1243,20 +1244,21 @@ async function runVmTests(method, state, traces) {
|
|
|
1243
1244
|
if (!vm.getVmContext) throw new TypeError(`Environment ${environment.name} doesn't provide "getVmContext" method. It should return a context created by "vm.createContext" method.`);
|
|
1244
1245
|
const context = vm.getVmContext();
|
|
1245
1246
|
if (!isContext(context)) throw new TypeError(`Environment ${environment.name} doesn't provide a valid context. It should be created by "vm.createContext" method.`);
|
|
1246
|
-
// captured before vitest installs its own globals (worker state, console,
|
|
1247
|
-
// mocker, executor symbol): they reference the test file's module graph, so
|
|
1248
|
-
// the teardown strip must treat them as removable, not as pristine
|
|
1249
|
-
const initialContextKeys = captureContextKeys(context);
|
|
1250
|
-
provideWorkerState(context, state);
|
|
1251
1247
|
// this is unfortunately needed for our own dependencies
|
|
1252
1248
|
// we need to find a way to not rely on this by default
|
|
1253
1249
|
// because browser doesn't provide these globals
|
|
1254
1250
|
context.process = process;
|
|
1255
1251
|
context.global = context;
|
|
1256
|
-
context.console = state.config.disableConsoleIntercept ? console : createCustomConsole(state);
|
|
1257
1252
|
// TODO: don't hardcode setImmediate in fake timers defaults
|
|
1258
1253
|
context.setImmediate = setImmediate;
|
|
1259
1254
|
context.clearImmediate = clearImmediate;
|
|
1255
|
+
// captured before vitest installs its own globals (worker state, console,
|
|
1256
|
+
// mocker, executor symbol): they reference the test file's module graph, so
|
|
1257
|
+
// the teardown strip must treat them as removable, not as pristine. The
|
|
1258
|
+
// globals above are kept, work a test file didn't await may still use them
|
|
1259
|
+
const initialContextKeys = captureContextKeys(context);
|
|
1260
|
+
provideWorkerState(context, state);
|
|
1261
|
+
context.console = state.config.disableConsoleIntercept ? console : createCustomConsole(state);
|
|
1260
1262
|
const stubs = getDefaultRequestStubs(context);
|
|
1261
1263
|
const externalModulesExecutor = new ExternalModulesExecutor({
|
|
1262
1264
|
context,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EvaluatedModules } from 'vite/module-runner';
|
|
2
|
-
import { F as FileSpecification, b as SerializedConfig, Y as Task, Z as CancelReason } from './config.d.
|
|
3
|
-
import { a as RuntimeRPC, R as RunnerRPC, G as GetterTracker } from './rpc.d.
|
|
4
|
-
import { E as Environment } from './environment.d.
|
|
2
|
+
import { F as FileSpecification, b as SerializedConfig, Y as Task, Z as CancelReason } from './config.d.BpJq6tRA.js';
|
|
3
|
+
import { a as RuntimeRPC, R as RunnerRPC, G as GetterTracker } from './rpc.d.DHfuwqP0.js';
|
|
4
|
+
import { E as Environment } from './environment.d.rlpAM-ON.js';
|
|
5
5
|
|
|
6
6
|
//#region src/messages.d.ts
|
|
7
7
|
declare const TYPE_REQUEST: "q";
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createCLI } from './chunks/cac.
|
|
2
|
-
import './chunks/pathe.M-eThtNZ.
|
|
1
|
+
import { c as createCLI } from './chunks/cac.BK306qhQ.js';
|
|
2
|
+
import './chunks/pathe.M-eThtNZ.zq3TM4NT.js';
|
|
3
3
|
import 'events';
|
|
4
4
|
import './chunks/tinyrainbow.Do8I1XRG.js';
|
|
5
5
|
import './chunks/env.BKKtU2WC.js';
|
package/dist/config.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { HookHandler, UserConfig, ConfigEnv } from 'vite';
|
|
2
2
|
export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
|
|
3
|
-
import { F as FieldsWithDefaultValues, U as UserWorkspaceConfig, a as UserProjectConfigFn, b as UserProjectConfigExport } from './chunks/plugin.d.
|
|
3
|
+
import { F as FieldsWithDefaultValues, U as UserWorkspaceConfig, a as UserProjectConfigFn, b as UserProjectConfigExport } from './chunks/plugin.d.Du7hHZwb.js';
|
|
4
4
|
import { InlineConfig, ResolvedConfig, VitestPluginContext, CoverageOptions } from './node.js';
|
|
5
|
-
export { T as TestProjectConfiguration, c as TestProjectInlineConfiguration, d as TestUserConfig, W as WatcherTriggerPattern } from './chunks/plugin.d.
|
|
5
|
+
export { T as TestProjectConfiguration, c as TestProjectInlineConfiguration, d as TestUserConfig, W as WatcherTriggerPattern } from './chunks/plugin.d.Du7hHZwb.js';
|
|
6
6
|
import { FakeTimersConfig } from './index.js';
|
|
7
|
-
export { g as TestTagDefinition } from './chunks/config.d.
|
|
7
|
+
export { g as TestTagDefinition } from './chunks/config.d.BpJq6tRA.js';
|
|
8
8
|
import 'node:stream';
|
|
9
|
-
import './chunks/browser.d.
|
|
10
|
-
import './chunks/rpc.d.
|
|
9
|
+
import './chunks/browser.d.B-QwH_F6.js';
|
|
10
|
+
import './chunks/rpc.d.DHfuwqP0.js';
|
|
11
11
|
import 'vite/module-runner';
|
|
12
|
-
import './chunks/worker.d.
|
|
13
|
-
import './chunks/environment.d.
|
|
12
|
+
import './chunks/worker.d.BigfbIsH.js';
|
|
13
|
+
import './chunks/environment.d.rlpAM-ON.js';
|
|
14
14
|
import 'chai';
|
|
15
15
|
import 'vitest/optional-types.js';
|
|
16
16
|
import '@vitest/mocker';
|
|
17
|
-
import './chunks/source-map.d.
|
|
17
|
+
import './chunks/source-map.d.xB6_75fl.js';
|
|
18
18
|
import 'vitest/browser';
|
|
19
19
|
import 'node:path';
|
|
20
20
|
import 'node:console';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/// <reference types="chai" />
|
|
2
|
-
import { a as File, A as Awaitable, h as TestAnnotation, j as TestArtifact, k as TaskResultPack, l as TaskEventPack, U as UserConsoleLog, m as SerializedRootConfig, L as LabelColor, M as ModuleGraphData, n as Test, o as TaskPopulated, E as ExpectStatic, p as ProvidedContext, q as MatcherState, r as SyncExpectationResult, t as AsyncExpectationResult, u as DomainSnapshotAdapter, v as ExpectationResult, w as Procedure, x as Mock, e as FakeTimersConfig, y as TemporalTimelike, z as spyOn, B as fn, C as MaybeMockedDeep, G as MaybeMocked, H as MaybePartiallyMocked, I as MaybePartiallyMockedDeep, J as MockInstance, R as RuntimeOptions, K as TestAPI, N as SuiteCollector, O as SuiteAPI, Q as Suite, W as SuiteHooks, V as VitestRunner, b as SerializedConfig, X as VitestRunnerImportSource, Y as Task, Z as CancelReason, $ as TestTryOptions, a0 as TestContext, a1 as ImportDuration, a2 as createChainable } from './chunks/config.d.
|
|
3
|
-
export { a3 as AfterSuiteRunMeta, a4 as Assertion, a5 as AsymmetricMatchersContaining, a6 as BaselineData, a7 as Bench, a8 as BenchFn, a9 as BenchFnOptions, aa as BenchFromSource, ab as BenchOptions, ac as BenchRegistration, ad as BenchRegistrationInput, ae as BenchResult, af as BenchRunOptions, ag as BenchStorage, ah as BenchmarkGroup, ai as BenchmarkProvider, aj as BrowserTraceArtifact, ak as DeeplyAllowMatchers, D as DiffOptions, al as DomainMatchResult, am as FailureScreenshotArtifact, an as JestAssertion, ao as Matcher, ap as Matchers, aq as MatchersObject, ar as MockContext, as as MockResult, at as MockResultIncomplete, au as MockResultReturn, av as MockResultThrow, aw as MockSettledResult, ax as MockSettledResultFulfilled, ay as MockSettledResultIncomplete, az as MockSettledResultRejected, aA as Mocked, aB as MockedClass, aC as MockedFunction, aD as MockedObject, aE as OnTestFailedHandler, aF as OnTestFinishedHandler, P as ParsedStack, aG as RunMode, aH as RunnerTaskBase, aI as RunnerTaskResult, aJ as RunnerTaskResultAttempt, aK as RuntimeConfig, S as SerializedCoverageConfig, aL as SerializedError, aM as SnapshotData, aN as SnapshotMatchOptions, aO as SnapshotResult, aP as SnapshotSerializer, aQ as SnapshotStateOptions, aR as SnapshotSummary, aS as SnapshotUpdateState, aT as SuiteFactory, aU as SuiteOptions, aV as TaskCustomOptions, aW as TaskMeta, aX as TaskState, aY as TestAnnotationArtifact, aZ as TestAnnotationLocation, a_ as TestArtifactBase, a$ as TestArtifactLocation, b0 as TestArtifactRegistry, b1 as TestAttachment, b2 as TestBenchmark, b3 as TestBenchmarkTask, T as TestError, b4 as TestFunction, b5 as TestOptions, g as TestTagDefinition, b6 as TestTags, b7 as UncheckedSnapshot, b8 as VisualRegressionArtifact, b9 as afterAll, ba as afterEach, bb as aroundAll, bc as aroundEach, bd as beforeAll, be as beforeEach, bf as onTestFailed, bg as onTestFinished } from './chunks/config.d.
|
|
4
|
-
import { M as ModuleDefinitionDurationsDiagnostic, U as UntrackedModuleDefinitionDiagnostic, S as SerializedTestSpecification, a as ModuleDefinitionDiagnostic, b as ModuleDefinitionLocation, c as SourceModuleDiagnostic, d as SourceModuleLocations } from './chunks/browser.d.
|
|
5
|
-
export { B as BrowserTesterOptions } from './chunks/browser.d.
|
|
6
|
-
import { c as createFileTask } from './chunks/task-utils.d.
|
|
7
|
-
import { B as BirpcReturn } from './chunks/worker.d.
|
|
8
|
-
export { C as ContextRPC, a as ContextTestEnvironment, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.
|
|
2
|
+
import { a as File, A as Awaitable, h as TestAnnotation, j as TestArtifact, k as TaskResultPack, l as TaskEventPack, U as UserConsoleLog, m as SerializedRootConfig, L as LabelColor, M as ModuleGraphData, n as Test, o as TaskPopulated, E as ExpectStatic, p as ProvidedContext, q as MatcherState, r as SyncExpectationResult, t as AsyncExpectationResult, u as DomainSnapshotAdapter, v as ExpectationResult, w as Procedure, x as Mock, e as FakeTimersConfig, y as TemporalTimelike, z as spyOn, B as fn, C as MaybeMockedDeep, G as MaybeMocked, H as MaybePartiallyMocked, I as MaybePartiallyMockedDeep, J as MockInstance, R as RuntimeOptions, K as TestAPI, N as SuiteCollector, O as SuiteAPI, Q as Suite, W as SuiteHooks, V as VitestRunner, b as SerializedConfig, X as VitestRunnerImportSource, Y as Task, Z as CancelReason, $ as TestTryOptions, a0 as TestContext, a1 as ImportDuration, a2 as createChainable } from './chunks/config.d.BpJq6tRA.js';
|
|
3
|
+
export { a3 as AfterSuiteRunMeta, a4 as Assertion, a5 as AsymmetricMatchersContaining, a6 as BaselineData, a7 as Bench, a8 as BenchFn, a9 as BenchFnOptions, aa as BenchFromSource, ab as BenchOptions, ac as BenchRegistration, ad as BenchRegistrationInput, ae as BenchResult, af as BenchRunOptions, ag as BenchStorage, ah as BenchmarkGroup, ai as BenchmarkProvider, aj as BrowserTraceArtifact, ak as DeeplyAllowMatchers, D as DiffOptions, al as DomainMatchResult, am as FailureScreenshotArtifact, an as JestAssertion, ao as Matcher, ap as Matchers, aq as MatchersObject, ar as MockContext, as as MockResult, at as MockResultIncomplete, au as MockResultReturn, av as MockResultThrow, aw as MockSettledResult, ax as MockSettledResultFulfilled, ay as MockSettledResultIncomplete, az as MockSettledResultRejected, aA as Mocked, aB as MockedClass, aC as MockedFunction, aD as MockedObject, aE as OnTestFailedHandler, aF as OnTestFinishedHandler, P as ParsedStack, aG as RunMode, aH as RunnerTaskBase, aI as RunnerTaskResult, aJ as RunnerTaskResultAttempt, aK as RuntimeConfig, S as SerializedCoverageConfig, aL as SerializedError, aM as SnapshotData, aN as SnapshotMatchOptions, aO as SnapshotResult, aP as SnapshotSerializer, aQ as SnapshotStateOptions, aR as SnapshotSummary, aS as SnapshotUpdateState, aT as SuiteFactory, aU as SuiteOptions, aV as TaskCustomOptions, aW as TaskMeta, aX as TaskState, aY as TestAnnotationArtifact, aZ as TestAnnotationLocation, a_ as TestArtifactBase, a$ as TestArtifactLocation, b0 as TestArtifactRegistry, b1 as TestAttachment, b2 as TestBenchmark, b3 as TestBenchmarkTask, T as TestError, b4 as TestFunction, b5 as TestOptions, g as TestTagDefinition, b6 as TestTags, b7 as UncheckedSnapshot, b8 as VisualRegressionArtifact, b9 as afterAll, ba as afterEach, bb as aroundAll, bc as aroundEach, bd as beforeAll, be as beforeEach, bf as onTestFailed, bg as onTestFinished } from './chunks/config.d.BpJq6tRA.js';
|
|
4
|
+
import { M as ModuleDefinitionDurationsDiagnostic, U as UntrackedModuleDefinitionDiagnostic, S as SerializedTestSpecification, a as ModuleDefinitionDiagnostic, b as ModuleDefinitionLocation, c as SourceModuleDiagnostic, d as SourceModuleLocations } from './chunks/browser.d.B-QwH_F6.js';
|
|
5
|
+
export { B as BrowserTesterOptions } from './chunks/browser.d.B-QwH_F6.js';
|
|
6
|
+
import { c as createFileTask } from './chunks/task-utils.d.DgSjIb7r.js';
|
|
7
|
+
import { B as BirpcReturn } from './chunks/worker.d.BigfbIsH.js';
|
|
8
|
+
export { C as ContextRPC, a as ContextTestEnvironment, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.BigfbIsH.js';
|
|
9
9
|
import { Disposable } from 'vitest/optional-runtime-types.js';
|
|
10
10
|
import { ModuleMockFactoryWithHelper, ModuleMockOptions } from '@vitest/mocker';
|
|
11
11
|
export { V as EvaluatedModules } from './chunks/evaluatedModules.d.BxJ5omdx.js';
|
|
12
|
-
import { T as Traces } from './chunks/rpc.d.
|
|
13
|
-
export { R as RunnerRPC, a as RuntimeRPC } from './chunks/rpc.d.
|
|
12
|
+
import { T as Traces } from './chunks/rpc.d.DHfuwqP0.js';
|
|
13
|
+
export { R as RunnerRPC, a as RuntimeRPC } from './chunks/rpc.d.DHfuwqP0.js';
|
|
14
14
|
export { ExpectTypeOf, expectTypeOf } from 'expect-type';
|
|
15
15
|
export { BenchOptions as BenchCompareOptions } from 'tinybench';
|
|
16
16
|
import * as chai from 'chai';
|
|
17
17
|
export { chai };
|
|
18
18
|
import 'vite/module-runner';
|
|
19
|
-
import './chunks/environment.d.
|
|
19
|
+
import './chunks/environment.d.rlpAM-ON.js';
|
|
20
20
|
|
|
21
21
|
interface SourceMap {
|
|
22
22
|
file: string;
|
|
@@ -414,10 +414,14 @@ interface WaitForOptions {
|
|
|
414
414
|
* @default 1000ms
|
|
415
415
|
*/
|
|
416
416
|
timeout?: number;
|
|
417
|
+
/**
|
|
418
|
+
* @description Message that describes what is being waited for. It prefixes the error and names the trace step
|
|
419
|
+
*/
|
|
420
|
+
message?: string;
|
|
417
421
|
}
|
|
418
422
|
declare function waitFor<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions): Promise<T>;
|
|
419
423
|
type WaitUntilCallback<T> = () => T | Promise<T>;
|
|
420
|
-
interface WaitUntilOptions extends Pick<WaitForOptions, "interval" | "timeout"> {}
|
|
424
|
+
interface WaitUntilOptions extends Pick<WaitForOptions, "interval" | "timeout" | "message"> {}
|
|
421
425
|
type Truthy<T> = T extends false | "" | 0 | null | undefined ? never : T;
|
|
422
426
|
declare function waitUntil<T>(callback: WaitUntilCallback<T>, options?: number | WaitUntilOptions): Promise<Truthy<T>>;
|
|
423
427
|
|
|
@@ -1030,7 +1034,8 @@ declare class TestRunner implements VitestRunner {
|
|
|
1030
1034
|
injectValue(key: string): any;
|
|
1031
1035
|
onBeforeRunTask(test: Task): Promise<void>;
|
|
1032
1036
|
onBeforeRunSuite(suite: Suite): Promise<void>;
|
|
1033
|
-
onBeforeTryTask(test: Task,
|
|
1037
|
+
onBeforeTryTask(test: Task, options: TestTryOptions): void;
|
|
1038
|
+
onAfterRetryTask(test: Test, _options: TestTryOptions): Promise<void>;
|
|
1034
1039
|
onAfterTryTask(test: Test): void;
|
|
1035
1040
|
extendTaskContext(context: TestContext): TestContext;
|
|
1036
1041
|
getImportDurations(): Record<string, ImportDuration>;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
export { S as Snapshots, T as TestRunner, a as assert, b as assertType, c as createExpect, g as expect, d as inject, s as should, v as vi, e as vitest } from './chunks/index.
|
|
2
|
-
export { V as EvaluatedModules } from './chunks/
|
|
3
|
-
export {
|
|
1
|
+
export { S as Snapshots, T as TestRunner, a as assert, b as assertType, c as createExpect, g as expect, d as inject, s as should, v as vi, e as vitest } from './chunks/index.DNcttN5a.js';
|
|
2
|
+
export { V as EvaluatedModules } from './chunks/index.CAmut2NG.js';
|
|
3
|
+
export { l as afterAll, n as afterEach, o as aroundAll, q as aroundEach, t as beforeAll, u as beforeEach, v as describe, w as it, x as onTestFailed, y as onTestFinished, e as recordArtifact, z as suite, A as test } from './chunks/run.zBhXlcZQ.js';
|
|
4
4
|
export { expectTypeOf } from 'expect-type';
|
|
5
5
|
import * as chai from 'chai';
|
|
6
6
|
export { chai };
|
|
7
7
|
import './chunks/utils.DYj33du9.js';
|
|
8
|
-
import './chunks/source-map.
|
|
9
|
-
import './chunks/index.
|
|
8
|
+
import './chunks/source-map.DPHGMWvM.js';
|
|
9
|
+
import './chunks/index.Or9psEGe.js';
|
|
10
10
|
import './chunks/tinyrainbow.Do8I1XRG.js';
|
|
11
|
-
import './chunks/pathe.M-eThtNZ.
|
|
12
|
-
import './chunks/spy.
|
|
13
|
-
import './chunks/display.
|
|
11
|
+
import './chunks/pathe.M-eThtNZ.zq3TM4NT.js';
|
|
12
|
+
import './chunks/spy.BO0hTE3G.js';
|
|
13
|
+
import './chunks/display.Cj2h2zsY.js';
|
|
14
14
|
import './task-utils.js';
|
|
15
|
-
import './chunks/plugins.
|
|
15
|
+
import './chunks/plugins.BPruPOR8.js';
|
|
16
|
+
import './chunks/rawSnapshot.DvoRLRNr.js';
|
|
16
17
|
import './chunks/offset.Dy-5Fdfn.js';
|
|
17
18
|
import 'tinybench';
|
|
19
|
+
import './chunks/rpc.CNYWPa97.js';
|
|
18
20
|
import 'vite/module-runner';
|
|
19
|
-
import './chunks/index.DmDMHCg8.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ModuleEvaluator, ModuleRunnerImportMeta, ModuleRunnerContext, EvaluatedModuleNode } from 'vite/module-runner';
|
|
2
|
-
import { G as GetterTracker } from './chunks/rpc.d.
|
|
2
|
+
import { G as GetterTracker } from './chunks/rpc.d.DHfuwqP0.js';
|
|
3
3
|
import { RuntimeRPC } from './index.js';
|
|
4
4
|
import { EvaluatedModules as VitestEvaluatedModules } from './index.js';
|
|
5
5
|
import vm from 'node:vm';
|
|
6
|
-
import './chunks/config.d.
|
|
6
|
+
import './chunks/config.d.BpJq6tRA.js';
|
|
7
7
|
import 'vitest/optional-runtime-types.js';
|
|
8
8
|
import 'tinybench';
|
|
9
9
|
|
|
@@ -174,7 +174,7 @@ declare class VitestModuleEvaluator implements ModuleEvaluator {
|
|
|
174
174
|
private debug;
|
|
175
175
|
private _otel;
|
|
176
176
|
private _evaluatedModules?;
|
|
177
|
-
constructor(vmOptions?: VitestVmOptions | undefined
|
|
177
|
+
constructor(options?: VitestModuleEvaluatorOptions, vmOptions?: VitestVmOptions | undefined);
|
|
178
178
|
private convertIdToImportUrl;
|
|
179
179
|
runExternalModule(id: string): Promise<any>;
|
|
180
180
|
runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
|
package/dist/module-evaluator.js
CHANGED
|
@@ -63,7 +63,7 @@ class VitestModuleEvaluator {
|
|
|
63
63
|
debug = new ModuleDebug();
|
|
64
64
|
_otel;
|
|
65
65
|
_evaluatedModules;
|
|
66
|
-
constructor(
|
|
66
|
+
constructor(options = {}, vmOptions) {
|
|
67
67
|
this.options = options;
|
|
68
68
|
this._otel = options.traces || new Traces({ enabled: false });
|
|
69
69
|
this.env = options.metaEnv ?? createImportMetaEnvProxy();
|