vitest 0.11.0 → 0.12.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/dist/{chunk-api-setup.87a943bf.js → chunk-api-setup.ed61899f.js} +1 -1
- package/dist/{chunk-defaults.23b3ae8a.js → chunk-defaults.ecb46baf.js} +15 -1
- package/dist/{chunk-integrations-globals.1ce15dfd.js → chunk-integrations-globals.60fc66ef.js} +3 -3
- package/dist/{chunk-runtime-chain.8a313ffb.js → chunk-runtime-chain.221b8dcb.js} +107 -83
- package/dist/{chunk-runtime-mocker.ee72d19a.js → chunk-runtime-mocker.acd615bd.js} +5 -2
- package/dist/{chunk-vite-node-externalize.d6642729.js → chunk-vite-node-externalize.2c1fbe22.js} +6 -6
- package/dist/{chunk-vite-node-utils.20782527.js → chunk-vite-node-utils.1536f168.js} +2 -7
- package/dist/cli.js +3 -3
- package/dist/config.cjs +15 -1
- package/dist/config.d.ts +67 -0
- package/dist/config.js +15 -1
- package/dist/entry.js +3 -3
- package/dist/index.d.ts +87 -13
- package/dist/index.js +1 -1
- package/dist/node.d.ts +86 -12
- package/dist/node.js +4 -4
- package/dist/{vendor-entry.1b0b46f1.js → vendor-entry.3adaf0b2.js} +116 -77
- package/dist/worker.js +3 -4
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-utils.
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-utils.1536f168.js';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -28,6 +28,19 @@ const coverageConfigDefaults = {
|
|
|
28
28
|
allowExternal: false,
|
|
29
29
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
30
30
|
};
|
|
31
|
+
const fakeTimersDefaults = {
|
|
32
|
+
loopLimit: 1e4,
|
|
33
|
+
shouldClearNativeTimers: true,
|
|
34
|
+
toFake: [
|
|
35
|
+
"setTimeout",
|
|
36
|
+
"clearTimeout",
|
|
37
|
+
"setInterval",
|
|
38
|
+
"clearInterval",
|
|
39
|
+
"setImmediate",
|
|
40
|
+
"clearImmediate",
|
|
41
|
+
"Date"
|
|
42
|
+
]
|
|
43
|
+
};
|
|
31
44
|
const config = {
|
|
32
45
|
allowOnly: !process.env.CI,
|
|
33
46
|
watch: !process.env.CI,
|
|
@@ -50,7 +63,8 @@ const config = {
|
|
|
50
63
|
ui: false,
|
|
51
64
|
uiBase: "/__vitest__/",
|
|
52
65
|
open: true,
|
|
53
|
-
coverage: coverageConfigDefaults
|
|
66
|
+
coverage: coverageConfigDefaults,
|
|
67
|
+
fakeTimers: fakeTimersDefaults
|
|
54
68
|
};
|
|
55
69
|
const configDefaults = Object.freeze(config);
|
|
56
70
|
|
package/dist/{chunk-integrations-globals.1ce15dfd.js → chunk-integrations-globals.60fc66ef.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as globalApis } from './chunk-constants.0567483c.js';
|
|
2
|
-
import { i as index } from './vendor-entry.
|
|
2
|
+
import { i as index } from './vendor-entry.3adaf0b2.js';
|
|
3
3
|
import 'url';
|
|
4
4
|
import './chunk-utils-global.a5a8641f.js';
|
|
5
5
|
import 'tty';
|
|
@@ -8,7 +8,7 @@ import 'path';
|
|
|
8
8
|
import 'fs';
|
|
9
9
|
import 'console';
|
|
10
10
|
import 'stream';
|
|
11
|
-
import './chunk-runtime-chain.
|
|
11
|
+
import './chunk-runtime-chain.221b8dcb.js';
|
|
12
12
|
import 'chai';
|
|
13
13
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
14
14
|
import './chunk-runtime-rpc.63398738.js';
|
|
@@ -16,7 +16,7 @@ import './chunk-utils-timers.f25e8f44.js';
|
|
|
16
16
|
import './chunk-integrations-spy.bee66426.js';
|
|
17
17
|
import 'tinyspy';
|
|
18
18
|
import 'util';
|
|
19
|
-
import './chunk-defaults.
|
|
19
|
+
import './chunk-defaults.ecb46baf.js';
|
|
20
20
|
import 'module';
|
|
21
21
|
import 'crypto';
|
|
22
22
|
|
|
@@ -7,21 +7,21 @@ import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n
|
|
|
7
7
|
import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.bee66426.js';
|
|
8
8
|
import require$$0, { format } from 'util';
|
|
9
9
|
|
|
10
|
-
var __defProp$
|
|
10
|
+
var __defProp$5 = Object.defineProperty;
|
|
11
11
|
var __defProps$2 = Object.defineProperties;
|
|
12
12
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
13
|
-
var __getOwnPropSymbols$
|
|
14
|
-
var __hasOwnProp$
|
|
15
|
-
var __propIsEnum$
|
|
16
|
-
var __defNormalProp$
|
|
17
|
-
var __spreadValues$
|
|
13
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
14
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
16
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
+
var __spreadValues$5 = (a, b) => {
|
|
18
18
|
for (var prop in b || (b = {}))
|
|
19
|
-
if (__hasOwnProp$
|
|
20
|
-
__defNormalProp$
|
|
21
|
-
if (__getOwnPropSymbols$
|
|
22
|
-
for (var prop of __getOwnPropSymbols$
|
|
23
|
-
if (__propIsEnum$
|
|
24
|
-
__defNormalProp$
|
|
19
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
20
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
21
|
+
if (__getOwnPropSymbols$5)
|
|
22
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
23
|
+
if (__propIsEnum$5.call(b, prop))
|
|
24
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
25
25
|
}
|
|
26
26
|
return a;
|
|
27
27
|
};
|
|
@@ -34,7 +34,7 @@ function createChainable(keys, fn) {
|
|
|
34
34
|
for (const key of keys) {
|
|
35
35
|
Object.defineProperty(chain2, key, {
|
|
36
36
|
get() {
|
|
37
|
-
return create(__spreadProps$2(__spreadValues$
|
|
37
|
+
return create(__spreadProps$2(__spreadValues$5({}, obj), { [key]: true }));
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -454,19 +454,19 @@ const addSerializer = (plugin) => {
|
|
|
454
454
|
};
|
|
455
455
|
const getSerializers = () => PLUGINS;
|
|
456
456
|
|
|
457
|
-
var __defProp$
|
|
458
|
-
var __getOwnPropSymbols$
|
|
459
|
-
var __hasOwnProp$
|
|
460
|
-
var __propIsEnum$
|
|
461
|
-
var __defNormalProp$
|
|
462
|
-
var __spreadValues$
|
|
457
|
+
var __defProp$4 = Object.defineProperty;
|
|
458
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
459
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
460
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
461
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
462
|
+
var __spreadValues$4 = (a, b) => {
|
|
463
463
|
for (var prop in b || (b = {}))
|
|
464
|
-
if (__hasOwnProp$
|
|
465
|
-
__defNormalProp$
|
|
466
|
-
if (__getOwnPropSymbols$
|
|
467
|
-
for (var prop of __getOwnPropSymbols$
|
|
468
|
-
if (__propIsEnum$
|
|
469
|
-
__defNormalProp$
|
|
464
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
465
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
466
|
+
if (__getOwnPropSymbols$4)
|
|
467
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
468
|
+
if (__propIsEnum$4.call(b, prop))
|
|
469
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
470
470
|
}
|
|
471
471
|
return a;
|
|
472
472
|
};
|
|
@@ -502,7 +502,7 @@ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith
|
|
|
502
502
|
const escapeRegex = true;
|
|
503
503
|
const printFunctionName = false;
|
|
504
504
|
function serialize(val, indent = 2, formatOverrides = {}) {
|
|
505
|
-
return normalizeNewlines(format_1(val, __spreadValues$
|
|
505
|
+
return normalizeNewlines(format_1(val, __spreadValues$4({
|
|
506
506
|
escapeRegex,
|
|
507
507
|
indent,
|
|
508
508
|
plugins: getSerializers(),
|
|
@@ -565,7 +565,7 @@ function deepMergeArray(target = [], source = []) {
|
|
|
565
565
|
}
|
|
566
566
|
function deepMergeSnapshot(target, source) {
|
|
567
567
|
if (isObject(target) && isObject(source)) {
|
|
568
|
-
const mergedOutput = __spreadValues$
|
|
568
|
+
const mergedOutput = __spreadValues$4({}, target);
|
|
569
569
|
Object.keys(source).forEach((key) => {
|
|
570
570
|
if (isObject(source[key]) && !source[key].$$typeof) {
|
|
571
571
|
if (!(key in target))
|
|
@@ -675,19 +675,19 @@ function stripSnapshotIndentation(inlineSnapshot) {
|
|
|
675
675
|
return inlineSnapshot;
|
|
676
676
|
}
|
|
677
677
|
|
|
678
|
-
var __defProp$
|
|
679
|
-
var __getOwnPropSymbols$
|
|
680
|
-
var __hasOwnProp$
|
|
681
|
-
var __propIsEnum$
|
|
682
|
-
var __defNormalProp$
|
|
683
|
-
var __spreadValues$
|
|
678
|
+
var __defProp$3 = Object.defineProperty;
|
|
679
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
680
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
681
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
682
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
683
|
+
var __spreadValues$3 = (a, b) => {
|
|
684
684
|
for (var prop in b || (b = {}))
|
|
685
|
-
if (__hasOwnProp$
|
|
686
|
-
__defNormalProp$
|
|
687
|
-
if (__getOwnPropSymbols$
|
|
688
|
-
for (var prop of __getOwnPropSymbols$
|
|
689
|
-
if (__propIsEnum$
|
|
690
|
-
__defNormalProp$
|
|
685
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
686
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
687
|
+
if (__getOwnPropSymbols$3)
|
|
688
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
689
|
+
if (__propIsEnum$3.call(b, prop))
|
|
690
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
691
691
|
}
|
|
692
692
|
return a;
|
|
693
693
|
};
|
|
@@ -708,7 +708,7 @@ class SnapshotState {
|
|
|
708
708
|
this.unmatched = 0;
|
|
709
709
|
this._updateSnapshot = options.updateSnapshot;
|
|
710
710
|
this.updated = 0;
|
|
711
|
-
this._snapshotFormat = __spreadValues$
|
|
711
|
+
this._snapshotFormat = __spreadValues$3({
|
|
712
712
|
printBasicPrototype: false
|
|
713
713
|
}, options.snapshotFormat);
|
|
714
714
|
}
|
|
@@ -736,7 +736,7 @@ class SnapshotState {
|
|
|
736
736
|
throw new Error(`Vitest: Couldn't infer stack frame for inline snapshot.
|
|
737
737
|
${JSON.stringify(stacks)}`);
|
|
738
738
|
}
|
|
739
|
-
this._inlineSnapshots.push(__spreadValues$
|
|
739
|
+
this._inlineSnapshots.push(__spreadValues$3({
|
|
740
740
|
snapshot: receivedSerialized
|
|
741
741
|
}, stack));
|
|
742
742
|
} else {
|
|
@@ -1058,15 +1058,15 @@ if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
|
|
|
1058
1058
|
expectedAssertionsNumber: null,
|
|
1059
1059
|
expectedAssertionsNumberErrorGen: null
|
|
1060
1060
|
};
|
|
1061
|
-
Object.defineProperty(
|
|
1061
|
+
Object.defineProperty(globalThis, MATCHERS_OBJECT, {
|
|
1062
1062
|
value: {
|
|
1063
1063
|
state: defaultState
|
|
1064
1064
|
}
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
1067
|
-
const getState = () =>
|
|
1067
|
+
const getState = () => globalThis[MATCHERS_OBJECT].state;
|
|
1068
1068
|
const setState = (state) => {
|
|
1069
|
-
Object.assign(
|
|
1069
|
+
Object.assign(globalThis[MATCHERS_OBJECT].state, state);
|
|
1070
1070
|
};
|
|
1071
1071
|
const JestChaiExpect = (chai, utils) => {
|
|
1072
1072
|
function def(name, fn) {
|
|
@@ -1448,21 +1448,21 @@ Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
|
|
|
1448
1448
|
utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
|
|
1449
1449
|
};
|
|
1450
1450
|
|
|
1451
|
-
var __defProp$
|
|
1451
|
+
var __defProp$2 = Object.defineProperty;
|
|
1452
1452
|
var __defProps$1 = Object.defineProperties;
|
|
1453
1453
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1454
|
-
var __getOwnPropSymbols$
|
|
1455
|
-
var __hasOwnProp$
|
|
1456
|
-
var __propIsEnum$
|
|
1457
|
-
var __defNormalProp$
|
|
1458
|
-
var __spreadValues$
|
|
1454
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1455
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1456
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1457
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1458
|
+
var __spreadValues$2 = (a, b) => {
|
|
1459
1459
|
for (var prop in b || (b = {}))
|
|
1460
|
-
if (__hasOwnProp$
|
|
1461
|
-
__defNormalProp$
|
|
1462
|
-
if (__getOwnPropSymbols$
|
|
1463
|
-
for (var prop of __getOwnPropSymbols$
|
|
1464
|
-
if (__propIsEnum$
|
|
1465
|
-
__defNormalProp$
|
|
1460
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
1461
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1462
|
+
if (__getOwnPropSymbols$2)
|
|
1463
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
1464
|
+
if (__propIsEnum$2.call(b, prop))
|
|
1465
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1466
1466
|
}
|
|
1467
1467
|
return a;
|
|
1468
1468
|
};
|
|
@@ -1474,7 +1474,7 @@ class AsymmetricMatcher {
|
|
|
1474
1474
|
this.$$typeof = Symbol.for("jest.asymmetricMatcher");
|
|
1475
1475
|
}
|
|
1476
1476
|
getMatcherContext() {
|
|
1477
|
-
return __spreadProps$1(__spreadValues$
|
|
1477
|
+
return __spreadProps$1(__spreadValues$2({}, getState()), {
|
|
1478
1478
|
equals,
|
|
1479
1479
|
isNot: this.inverse,
|
|
1480
1480
|
utils: matcherUtils
|
|
@@ -1648,21 +1648,21 @@ const JestAsymmetricMatchers = (chai, utils) => {
|
|
|
1648
1648
|
};
|
|
1649
1649
|
};
|
|
1650
1650
|
|
|
1651
|
-
var __defProp = Object.defineProperty;
|
|
1651
|
+
var __defProp$1 = Object.defineProperty;
|
|
1652
1652
|
var __defProps = Object.defineProperties;
|
|
1653
1653
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1654
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1655
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1656
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1657
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1658
|
-
var __spreadValues = (a, b) => {
|
|
1654
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1655
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1656
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1657
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1658
|
+
var __spreadValues$1 = (a, b) => {
|
|
1659
1659
|
for (var prop in b || (b = {}))
|
|
1660
|
-
if (__hasOwnProp.call(b, prop))
|
|
1661
|
-
__defNormalProp(a, prop, b[prop]);
|
|
1662
|
-
if (__getOwnPropSymbols)
|
|
1663
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
1664
|
-
if (__propIsEnum.call(b, prop))
|
|
1665
|
-
__defNormalProp(a, prop, b[prop]);
|
|
1660
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
1661
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1662
|
+
if (__getOwnPropSymbols$1)
|
|
1663
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1664
|
+
if (__propIsEnum$1.call(b, prop))
|
|
1665
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1666
1666
|
}
|
|
1667
1667
|
return a;
|
|
1668
1668
|
};
|
|
@@ -1672,11 +1672,11 @@ const getMatcherState = (assertion) => {
|
|
|
1672
1672
|
const obj = assertion._obj;
|
|
1673
1673
|
const isNot = util.flag(assertion, "negate");
|
|
1674
1674
|
const promise = util.flag(assertion, "promise") || "";
|
|
1675
|
-
const jestUtils = __spreadProps(__spreadValues({}, matcherUtils), {
|
|
1675
|
+
const jestUtils = __spreadProps(__spreadValues$1({}, matcherUtils), {
|
|
1676
1676
|
iterableEquality,
|
|
1677
1677
|
subsetEquality
|
|
1678
1678
|
});
|
|
1679
|
-
const matcherState = __spreadProps(__spreadValues({}, getState()), {
|
|
1679
|
+
const matcherState = __spreadProps(__spreadValues$1({}, getState()), {
|
|
1680
1680
|
isNot,
|
|
1681
1681
|
utils: jestUtils,
|
|
1682
1682
|
promise,
|
|
@@ -4572,13 +4572,29 @@ function resetDate() {
|
|
|
4572
4572
|
globalThis.Date = RealDate;
|
|
4573
4573
|
}
|
|
4574
4574
|
|
|
4575
|
+
var __defProp = Object.defineProperty;
|
|
4576
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4577
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4578
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4579
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4580
|
+
var __spreadValues = (a, b) => {
|
|
4581
|
+
for (var prop in b || (b = {}))
|
|
4582
|
+
if (__hasOwnProp.call(b, prop))
|
|
4583
|
+
__defNormalProp(a, prop, b[prop]);
|
|
4584
|
+
if (__getOwnPropSymbols)
|
|
4585
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
4586
|
+
if (__propIsEnum.call(b, prop))
|
|
4587
|
+
__defNormalProp(a, prop, b[prop]);
|
|
4588
|
+
}
|
|
4589
|
+
return a;
|
|
4590
|
+
};
|
|
4575
4591
|
class FakeTimers {
|
|
4576
4592
|
constructor({
|
|
4577
4593
|
global,
|
|
4578
|
-
|
|
4594
|
+
config
|
|
4579
4595
|
}) {
|
|
4580
4596
|
this._now = RealDate.now;
|
|
4581
|
-
this.
|
|
4597
|
+
this._userConfig = config;
|
|
4582
4598
|
this._fakingDate = false;
|
|
4583
4599
|
this._fakingTime = false;
|
|
4584
4600
|
this._fakeTimers = withGlobal_1(global);
|
|
@@ -4633,12 +4649,10 @@ class FakeTimers {
|
|
|
4633
4649
|
}
|
|
4634
4650
|
if (!this._fakingTime) {
|
|
4635
4651
|
const toFake = Object.keys(this._fakeTimers.timers);
|
|
4636
|
-
this._clock = this._fakeTimers.install({
|
|
4637
|
-
loopLimit: this._maxLoops,
|
|
4652
|
+
this._clock = this._fakeTimers.install(__spreadValues({
|
|
4638
4653
|
now: Date.now(),
|
|
4639
|
-
toFake
|
|
4640
|
-
|
|
4641
|
-
});
|
|
4654
|
+
toFake
|
|
4655
|
+
}, this._userConfig));
|
|
4642
4656
|
this._fakingTime = true;
|
|
4643
4657
|
}
|
|
4644
4658
|
}
|
|
@@ -4665,6 +4679,9 @@ class FakeTimers {
|
|
|
4665
4679
|
return this._clock.countTimers();
|
|
4666
4680
|
return 0;
|
|
4667
4681
|
}
|
|
4682
|
+
configure(config) {
|
|
4683
|
+
this._userConfig = config;
|
|
4684
|
+
}
|
|
4668
4685
|
_checkFakeTimers() {
|
|
4669
4686
|
if (!this._fakingTime) {
|
|
4670
4687
|
throw new Error('Timers are not mocked. Try calling "vi.useFakeTimers()" first.');
|
|
@@ -4677,18 +4694,25 @@ class VitestUtils {
|
|
|
4677
4694
|
constructor() {
|
|
4678
4695
|
this.spyOn = spyOn;
|
|
4679
4696
|
this.fn = fn;
|
|
4680
|
-
this._timers = new FakeTimers({
|
|
4681
|
-
global: globalThis,
|
|
4682
|
-
maxLoops: 1e4
|
|
4683
|
-
});
|
|
4684
4697
|
this._mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : null;
|
|
4685
4698
|
this._mockedDate = null;
|
|
4686
4699
|
if (!this._mocker) {
|
|
4687
4700
|
const errorMsg = 'Vitest was initialized with native Node instead of Vite Node.\n\nOne of the following is possible:\n- "vitest" is imported outside of your tests (in that case, use "vitest/node" or import.meta.vitest)\n- "vitest" is imported inside "globalSetup" (use "setupFiles", because "globalSetup" runs in a different context)\n- Your dependency inside "node_modules" imports "vitest" directly (in that case, inline that dependency, using "deps.inline" config)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
|
|
4688
4701
|
throw new Error(errorMsg);
|
|
4689
4702
|
}
|
|
4703
|
+
const workerState = getWorkerState();
|
|
4704
|
+
this._timers = new FakeTimers({
|
|
4705
|
+
global: globalThis,
|
|
4706
|
+
config: workerState.config.fakeTimers
|
|
4707
|
+
});
|
|
4690
4708
|
}
|
|
4691
|
-
useFakeTimers() {
|
|
4709
|
+
useFakeTimers(config) {
|
|
4710
|
+
if (config) {
|
|
4711
|
+
this._timers.configure(config);
|
|
4712
|
+
} else {
|
|
4713
|
+
const workerState = getWorkerState();
|
|
4714
|
+
this._timers.configure(workerState.config.fakeTimers);
|
|
4715
|
+
}
|
|
4692
4716
|
this._timers.useFakeTimers();
|
|
4693
4717
|
return this;
|
|
4694
4718
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
1
|
+
import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.1536f168.js';
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
3
|
import { a as getWorkerState, C as isWindows, D as mergeSlashes, d as dirname, f as basename, h as resolve, E as getType, F as getAllProperties, s as slash } from './chunk-utils-global.a5a8641f.js';
|
|
4
4
|
import { existsSync, readdirSync } from 'fs';
|
|
@@ -191,7 +191,10 @@ const _VitestMocker = class {
|
|
|
191
191
|
}
|
|
192
192
|
if (typeof mock === "function" && !callstack.includes(`mock:${dep}`)) {
|
|
193
193
|
callstack.push(`mock:${dep}`);
|
|
194
|
-
|
|
194
|
+
const result = await this.callFunctionMock(dep, mock);
|
|
195
|
+
const indexMock = callstack.indexOf(`mock:${dep}`);
|
|
196
|
+
callstack.splice(indexMock, 1);
|
|
197
|
+
return result;
|
|
195
198
|
}
|
|
196
199
|
if (typeof mock === "string" && !callstack.includes(mock))
|
|
197
200
|
dep = mock;
|
package/dist/{chunk-vite-node-externalize.d6642729.js → chunk-vite-node-externalize.2c1fbe22.js}
RENAMED
|
@@ -14,8 +14,8 @@ import require$$0$1 from 'util';
|
|
|
14
14
|
import require$$0$2 from 'stream';
|
|
15
15
|
import require$$2 from 'events';
|
|
16
16
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
17
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
18
|
-
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.
|
|
17
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.1536f168.js';
|
|
18
|
+
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.ecb46baf.js';
|
|
19
19
|
import { MessageChannel } from 'worker_threads';
|
|
20
20
|
import { Tinypool } from 'tinypool';
|
|
21
21
|
import { performance } from 'perf_hooks';
|
|
@@ -23,7 +23,7 @@ import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as
|
|
|
23
23
|
import MagicString from './chunk-magic-string.d5e0e473.js';
|
|
24
24
|
import { p as prompts } from './vendor-index.405e58ef.js';
|
|
25
25
|
|
|
26
|
-
var version = "0.
|
|
26
|
+
var version = "0.12.2";
|
|
27
27
|
|
|
28
28
|
function stripFinalNewline(input) {
|
|
29
29
|
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|
@@ -8201,7 +8201,6 @@ function createFakePool(ctx) {
|
|
|
8201
8201
|
};
|
|
8202
8202
|
return {
|
|
8203
8203
|
runTests: runWithFiles("run"),
|
|
8204
|
-
collectTests: runWithFiles("collect"),
|
|
8205
8204
|
close: async () => {
|
|
8206
8205
|
}
|
|
8207
8206
|
};
|
|
@@ -8239,7 +8238,6 @@ function createWorkerPool(ctx) {
|
|
|
8239
8238
|
};
|
|
8240
8239
|
return {
|
|
8241
8240
|
runTests: runWithFiles("run"),
|
|
8242
|
-
collectTests: runWithFiles("collect"),
|
|
8243
8241
|
close: async () => {
|
|
8244
8242
|
}
|
|
8245
8243
|
};
|
|
@@ -10938,7 +10936,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10938
10936
|
await ctx.setServer(options, server);
|
|
10939
10937
|
haveStarted = true;
|
|
10940
10938
|
if (options.api && options.watch)
|
|
10941
|
-
(await import('./chunk-api-setup.
|
|
10939
|
+
(await import('./chunk-api-setup.ed61899f.js')).setup(ctx);
|
|
10942
10940
|
if (!options.watch)
|
|
10943
10941
|
await server.watcher.close();
|
|
10944
10942
|
}
|
|
@@ -11048,6 +11046,8 @@ async function startVitest(cliFilters, options, viteOverrides) {
|
|
|
11048
11046
|
options.coverage = { enabled: options.coverage };
|
|
11049
11047
|
const ctx = await createVitest(options, viteOverrides);
|
|
11050
11048
|
process.env.VITEST_MODE = ctx.config.watch ? "WATCH" : "RUN";
|
|
11049
|
+
if (ctx.config.env)
|
|
11050
|
+
Object.assign(process.env, ctx.config.env);
|
|
11051
11051
|
if (ctx.config.coverage.enabled) {
|
|
11052
11052
|
if (!await ensurePackageInstalled("c8")) {
|
|
11053
11053
|
process.exitCode = 1;
|
|
@@ -9003,10 +9003,9 @@ ${getStack()}`), 2e3);
|
|
|
9003
9003
|
exports.default = value;
|
|
9004
9004
|
},
|
|
9005
9005
|
get exports() {
|
|
9006
|
-
return exports
|
|
9006
|
+
return exports;
|
|
9007
9007
|
}
|
|
9008
9008
|
};
|
|
9009
|
-
let require;
|
|
9010
9009
|
const context = this.prepareContext({
|
|
9011
9010
|
__vite_ssr_import__: request,
|
|
9012
9011
|
__vite_ssr_dynamic_import__: request,
|
|
@@ -9014,11 +9013,7 @@ ${getStack()}`), 2e3);
|
|
|
9014
9013
|
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
9015
9014
|
__vite_ssr_import_meta__: { url },
|
|
9016
9015
|
__vitest_resolve_id__: resolveId,
|
|
9017
|
-
require: (
|
|
9018
|
-
if (!require)
|
|
9019
|
-
require = createRequire(url);
|
|
9020
|
-
return require(path);
|
|
9021
|
-
},
|
|
9016
|
+
require: createRequire(url),
|
|
9022
9017
|
exports,
|
|
9023
9018
|
module: moduleProxy,
|
|
9024
9019
|
__filename,
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { p as picocolors } from './chunk-utils-global.a5a8641f.js';
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.2c1fbe22.js';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
@@ -18,10 +18,10 @@ import 'os';
|
|
|
18
18
|
import 'vite';
|
|
19
19
|
import './chunk-constants.0567483c.js';
|
|
20
20
|
import 'readline';
|
|
21
|
-
import './chunk-vite-node-utils.
|
|
21
|
+
import './chunk-vite-node-utils.1536f168.js';
|
|
22
22
|
import 'module';
|
|
23
23
|
import 'vm';
|
|
24
|
-
import './chunk-defaults.
|
|
24
|
+
import './chunk-defaults.ecb46baf.js';
|
|
25
25
|
import 'worker_threads';
|
|
26
26
|
import 'tinypool';
|
|
27
27
|
import 'perf_hooks';
|
package/dist/config.cjs
CHANGED
|
@@ -27,6 +27,19 @@ const coverageConfigDefaults = {
|
|
|
27
27
|
allowExternal: false,
|
|
28
28
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
29
29
|
};
|
|
30
|
+
const fakeTimersDefaults = {
|
|
31
|
+
loopLimit: 1e4,
|
|
32
|
+
shouldClearNativeTimers: true,
|
|
33
|
+
toFake: [
|
|
34
|
+
"setTimeout",
|
|
35
|
+
"clearTimeout",
|
|
36
|
+
"setInterval",
|
|
37
|
+
"clearInterval",
|
|
38
|
+
"setImmediate",
|
|
39
|
+
"clearImmediate",
|
|
40
|
+
"Date"
|
|
41
|
+
]
|
|
42
|
+
};
|
|
30
43
|
const config = {
|
|
31
44
|
allowOnly: !process.env.CI,
|
|
32
45
|
watch: !process.env.CI,
|
|
@@ -49,7 +62,8 @@ const config = {
|
|
|
49
62
|
ui: false,
|
|
50
63
|
uiBase: "/__vitest__/",
|
|
51
64
|
open: true,
|
|
52
|
-
coverage: coverageConfigDefaults
|
|
65
|
+
coverage: coverageConfigDefaults,
|
|
66
|
+
fakeTimers: fakeTimersDefaults
|
|
53
67
|
};
|
|
54
68
|
const configDefaults = Object.freeze(config);
|
|
55
69
|
|
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
import { UserConfig as UserConfig$2 } from 'vite';
|
|
2
2
|
import { UserConfig as UserConfig$1, ResolvedC8Options } from 'vitest';
|
|
3
3
|
|
|
4
|
+
// Type definitions for @sinonjs/fake-timers 8.1
|
|
5
|
+
// Project: https://github.com/sinonjs/fake-timers
|
|
6
|
+
// Definitions by: Wim Looman <https://github.com/Nemo157>
|
|
7
|
+
// Rogier Schouten <https://github.com/rogierschouten>
|
|
8
|
+
// Yishai Zehavi <https://github.com/zyishai>
|
|
9
|
+
// Remco Haszing <https://github.com/remcohaszing>
|
|
10
|
+
// Jaden Simon <https://github.com/JadenSimon>
|
|
11
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
12
|
+
// TypeScript Version: 2.3
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Names of clock methods that may be faked by install.
|
|
16
|
+
*/
|
|
17
|
+
type FakeMethod =
|
|
18
|
+
| 'setTimeout'
|
|
19
|
+
| 'clearTimeout'
|
|
20
|
+
| 'setImmediate'
|
|
21
|
+
| 'clearImmediate'
|
|
22
|
+
| 'setInterval'
|
|
23
|
+
| 'clearInterval'
|
|
24
|
+
| 'Date'
|
|
25
|
+
| 'nextTick'
|
|
26
|
+
| 'hrtime'
|
|
27
|
+
| 'requestAnimationFrame'
|
|
28
|
+
| 'cancelAnimationFrame'
|
|
29
|
+
| 'requestIdleCallback'
|
|
30
|
+
| 'cancelIdleCallback'
|
|
31
|
+
| 'performance'
|
|
32
|
+
| 'queueMicrotask';
|
|
33
|
+
|
|
34
|
+
interface FakeTimerInstallOpts {
|
|
35
|
+
/**
|
|
36
|
+
* Installs fake timers with the specified unix epoch (default: 0)
|
|
37
|
+
*/
|
|
38
|
+
now?: number | Date | undefined;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
|
|
42
|
+
* For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
|
|
43
|
+
*/
|
|
44
|
+
toFake?: FakeMethod[] | undefined;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The maximum number of timers that will be run when calling runAll() (default: 1000)
|
|
48
|
+
*/
|
|
49
|
+
loopLimit?: number | undefined;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
|
|
53
|
+
* 20ms for every 20ms change in the real system time) (default: false)
|
|
54
|
+
*/
|
|
55
|
+
shouldAdvanceTime?: boolean | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
|
|
59
|
+
* in the real system time (default: 20)
|
|
60
|
+
*/
|
|
61
|
+
advanceTimeDelta?: number | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
|
|
65
|
+
* default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
|
|
66
|
+
*/
|
|
67
|
+
shouldClearNativeTimers?: boolean | undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
4
70
|
declare const config: {
|
|
5
71
|
allowOnly: boolean;
|
|
6
72
|
watch: boolean;
|
|
@@ -24,6 +90,7 @@ declare const config: {
|
|
|
24
90
|
uiBase: string;
|
|
25
91
|
open: boolean;
|
|
26
92
|
coverage: ResolvedC8Options;
|
|
93
|
+
fakeTimers: FakeTimerInstallOpts;
|
|
27
94
|
};
|
|
28
95
|
declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
|
|
29
96
|
|
package/dist/config.js
CHANGED
|
@@ -23,6 +23,19 @@ const coverageConfigDefaults = {
|
|
|
23
23
|
allowExternal: false,
|
|
24
24
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
25
25
|
};
|
|
26
|
+
const fakeTimersDefaults = {
|
|
27
|
+
loopLimit: 1e4,
|
|
28
|
+
shouldClearNativeTimers: true,
|
|
29
|
+
toFake: [
|
|
30
|
+
"setTimeout",
|
|
31
|
+
"clearTimeout",
|
|
32
|
+
"setInterval",
|
|
33
|
+
"clearInterval",
|
|
34
|
+
"setImmediate",
|
|
35
|
+
"clearImmediate",
|
|
36
|
+
"Date"
|
|
37
|
+
]
|
|
38
|
+
};
|
|
26
39
|
const config = {
|
|
27
40
|
allowOnly: !process.env.CI,
|
|
28
41
|
watch: !process.env.CI,
|
|
@@ -45,7 +58,8 @@ const config = {
|
|
|
45
58
|
ui: false,
|
|
46
59
|
uiBase: "/__vitest__/",
|
|
47
60
|
open: true,
|
|
48
|
-
coverage: coverageConfigDefaults
|
|
61
|
+
coverage: coverageConfigDefaults,
|
|
62
|
+
fakeTimers: fakeTimersDefaults
|
|
49
63
|
};
|
|
50
64
|
const configDefaults = Object.freeze(config);
|
|
51
65
|
|