vitest 0.8.3 → 0.9.0
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.175eacf7.js → chunk-api-setup.e8071f5b.js} +4 -4
- package/dist/{chunk-constants.6062c404.js → chunk-constants.596ee4d5.js} +1 -1
- package/dist/{chunk-defaults.e5535971.js → chunk-defaults.731639a8.js} +4 -3
- package/dist/chunk-integrations-globals.d1145578.js +23 -0
- package/dist/{chunk-runtime-chain.766f27fd.js → chunk-runtime-chain.a5280da7.js} +232 -171
- package/dist/{chunk-runtime-mocker.def94aba.js → chunk-runtime-mocker.ff55be7d.js} +32 -35
- package/dist/chunk-runtime-rpc.3f693817.js +7 -0
- package/dist/{chunk-utils-base.8408f73a.js → chunk-utils-global.35d3b35d.js} +18 -1
- package/dist/{chunk-utils-timers.7bdeea22.js → chunk-utils-timers.73950dcb.js} +13 -10
- package/dist/{chunk-vite-node-externalize.ecc58a1f.js → chunk-vite-node-externalize.2004587d.js} +233 -76
- package/dist/{chunk-vite-node-utils.3c7ce184.js → chunk-vite-node-utils.5fa30ee7.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/config.cjs +3 -2
- package/dist/config.d.ts +26 -2
- package/dist/config.js +3 -2
- package/dist/entry.js +85 -53
- package/dist/index.d.ts +29 -10
- package/dist/index.js +5 -6
- package/dist/node.d.ts +21 -4
- package/dist/node.js +7 -8
- package/dist/{jest-mock.js → spy.js} +3 -0
- package/dist/worker.js +5 -6
- package/package.json +16 -16
- package/dist/chunk-integrations-globals.ade0c248.js +0 -24
- package/dist/chunk-runtime-rpc.e8aa1ebe.js +0 -8
- package/dist/chunk-utils-global.7bcfa03c.js +0 -5
|
@@ -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.5fa30ee7.js';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -9,11 +9,11 @@ import require$$2 from 'events';
|
|
|
9
9
|
import require$$1 from 'https';
|
|
10
10
|
import require$$2$1 from 'http';
|
|
11
11
|
import url from 'url';
|
|
12
|
-
import { A as API_PATH } from './chunk-constants.
|
|
13
|
-
import { k as interpretSourcePos, a as parseStacktrace } from './chunk-utils-timers.
|
|
12
|
+
import { A as API_PATH } from './chunk-constants.596ee4d5.js';
|
|
13
|
+
import { k as interpretSourcePos, a as parseStacktrace } from './chunk-utils-timers.73950dcb.js';
|
|
14
14
|
import 'module';
|
|
15
15
|
import 'vm';
|
|
16
|
-
import './chunk-utils-
|
|
16
|
+
import './chunk-utils-global.35d3b35d.js';
|
|
17
17
|
import 'path';
|
|
18
18
|
import 'tty';
|
|
19
19
|
import 'local-pkg';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import {
|
|
2
|
+
import { w as resolve } from './chunk-utils-global.35d3b35d.js';
|
|
3
3
|
|
|
4
4
|
const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
5
5
|
const defaultPort = 51204;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises } from 'fs';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
|
-
import { t as toArray,
|
|
4
|
+
import { t as toArray, w as resolve } from './chunk-utils-global.35d3b35d.js';
|
|
5
5
|
|
|
6
6
|
const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
7
7
|
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
|
|
@@ -28,7 +28,7 @@ const coverageConfigDefaults = {
|
|
|
28
28
|
allowExternal: false,
|
|
29
29
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
30
30
|
};
|
|
31
|
-
const
|
|
31
|
+
const config = {
|
|
32
32
|
allowOnly: !process.env.CI,
|
|
33
33
|
watch: !process.env.CI,
|
|
34
34
|
globals: false,
|
|
@@ -51,7 +51,8 @@ const configDefaults = Object.freeze({
|
|
|
51
51
|
uiBase: "/__vitest__/",
|
|
52
52
|
open: true,
|
|
53
53
|
coverage: coverageConfigDefaults
|
|
54
|
-
}
|
|
54
|
+
};
|
|
55
|
+
const configDefaults = Object.freeze(config);
|
|
55
56
|
|
|
56
57
|
var __defProp = Object.defineProperty;
|
|
57
58
|
var __defProps = Object.defineProperties;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { g as globalApis } from './chunk-constants.596ee4d5.js';
|
|
2
|
+
import { i as index } from './chunk-runtime-chain.a5280da7.js';
|
|
3
|
+
import 'url';
|
|
4
|
+
import './chunk-utils-global.35d3b35d.js';
|
|
5
|
+
import 'path';
|
|
6
|
+
import 'tty';
|
|
7
|
+
import 'local-pkg';
|
|
8
|
+
import 'util';
|
|
9
|
+
import './chunk-utils-timers.73950dcb.js';
|
|
10
|
+
import 'chai';
|
|
11
|
+
import './vendor-_commonjsHelpers.34b404ce.js';
|
|
12
|
+
import './chunk-runtime-rpc.3f693817.js';
|
|
13
|
+
import 'fs';
|
|
14
|
+
import './spy.js';
|
|
15
|
+
import 'tinyspy';
|
|
16
|
+
|
|
17
|
+
function registerApiGlobally() {
|
|
18
|
+
globalApis.forEach((api) => {
|
|
19
|
+
globalThis[api] = index[api];
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { registerApiGlobally };
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import require$$0, { format as format$1 } from 'util';
|
|
2
|
-
import { i as isObject, t as toArray, n as noop, a as index$1,
|
|
3
|
-
import { g as
|
|
4
|
-
import { s as setTimeout, c as clearTimeout, g as getOriginalPos, p as posToNumber, n as numberToPos, l as lineSplitRE, a as parseStacktrace, u as unifiedDiff } from './chunk-utils-timers.7bdeea22.js';
|
|
2
|
+
import { g as getWorkerState, i as isObject, t as toArray, n as noop, a as index$1, b as getCallLastIndex, s as slash, c as getNames, d as c$1, e as assertTypes, r as resetModules } from './chunk-utils-global.35d3b35d.js';
|
|
3
|
+
import { s as setTimeout, c as clearTimeout, g as getOriginalPos, p as posToNumber, n as numberToPos, l as lineSplitRE, a as parseStacktrace, u as unifiedDiff } from './chunk-utils-timers.73950dcb.js';
|
|
5
4
|
import chai$1, { expect as expect$1, util, assert, should } from 'chai';
|
|
6
5
|
import { c as commonjsRequire, a as commonjsGlobal } from './vendor-_commonjsHelpers.34b404ce.js';
|
|
7
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.3f693817.js';
|
|
8
7
|
import fs, { promises } from 'fs';
|
|
9
|
-
import { isMockFunction, spyOn, fn, spies } from './
|
|
8
|
+
import { isMockFunction, spyOn, fn, spies } from './spy.js';
|
|
10
9
|
|
|
11
|
-
var __defProp$
|
|
10
|
+
var __defProp$5 = Object.defineProperty;
|
|
12
11
|
var __defProps$2 = Object.defineProperties;
|
|
13
12
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
14
|
-
var __getOwnPropSymbols$
|
|
15
|
-
var __hasOwnProp$
|
|
16
|
-
var __propIsEnum$
|
|
17
|
-
var __defNormalProp$
|
|
18
|
-
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) => {
|
|
19
18
|
for (var prop in b || (b = {}))
|
|
20
|
-
if (__hasOwnProp$
|
|
21
|
-
__defNormalProp$
|
|
22
|
-
if (__getOwnPropSymbols$
|
|
23
|
-
for (var prop of __getOwnPropSymbols$
|
|
24
|
-
if (__propIsEnum$
|
|
25
|
-
__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]);
|
|
26
25
|
}
|
|
27
26
|
return a;
|
|
28
27
|
};
|
|
@@ -35,7 +34,7 @@ function createChainable(keys, fn) {
|
|
|
35
34
|
for (const key of keys) {
|
|
36
35
|
Object.defineProperty(chain2, key, {
|
|
37
36
|
get() {
|
|
38
|
-
return create(__spreadProps$2(__spreadValues$
|
|
37
|
+
return create(__spreadProps$2(__spreadValues$5({}, obj), { [key]: true }));
|
|
39
38
|
}
|
|
40
39
|
});
|
|
41
40
|
}
|
|
@@ -2980,19 +2979,19 @@ const addSerializer = (plugin) => {
|
|
|
2980
2979
|
};
|
|
2981
2980
|
const getSerializers = () => PLUGINS$1;
|
|
2982
2981
|
|
|
2983
|
-
var __defProp$
|
|
2984
|
-
var __getOwnPropSymbols$
|
|
2985
|
-
var __hasOwnProp$
|
|
2986
|
-
var __propIsEnum$
|
|
2987
|
-
var __defNormalProp$
|
|
2988
|
-
var __spreadValues$
|
|
2982
|
+
var __defProp$4 = Object.defineProperty;
|
|
2983
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
2984
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
2985
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
2986
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2987
|
+
var __spreadValues$4 = (a, b) => {
|
|
2989
2988
|
for (var prop in b || (b = {}))
|
|
2990
|
-
if (__hasOwnProp$
|
|
2991
|
-
__defNormalProp$
|
|
2992
|
-
if (__getOwnPropSymbols$
|
|
2993
|
-
for (var prop of __getOwnPropSymbols$
|
|
2994
|
-
if (__propIsEnum$
|
|
2995
|
-
__defNormalProp$
|
|
2989
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
2990
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
2991
|
+
if (__getOwnPropSymbols$4)
|
|
2992
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
2993
|
+
if (__propIsEnum$4.call(b, prop))
|
|
2994
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
2996
2995
|
}
|
|
2997
2996
|
return a;
|
|
2998
2997
|
};
|
|
@@ -3028,7 +3027,7 @@ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith
|
|
|
3028
3027
|
const escapeRegex = true;
|
|
3029
3028
|
const printFunctionName = false;
|
|
3030
3029
|
function serialize(val, indent = 2, formatOverrides = {}) {
|
|
3031
|
-
return normalizeNewlines(format_1(val, __spreadValues$
|
|
3030
|
+
return normalizeNewlines(format_1(val, __spreadValues$4({
|
|
3032
3031
|
escapeRegex,
|
|
3033
3032
|
indent,
|
|
3034
3033
|
plugins: getSerializers(),
|
|
@@ -3087,7 +3086,7 @@ function deepMergeArray(target = [], source = []) {
|
|
|
3087
3086
|
}
|
|
3088
3087
|
function deepMergeSnapshot(target, source) {
|
|
3089
3088
|
if (isObject(target) && isObject(source)) {
|
|
3090
|
-
const mergedOutput = __spreadValues$
|
|
3089
|
+
const mergedOutput = __spreadValues$4({}, target);
|
|
3091
3090
|
Object.keys(source).forEach((key) => {
|
|
3092
3091
|
if (isObject(source[key]) && !source[key].$$typeof) {
|
|
3093
3092
|
if (!(key in target))
|
|
@@ -3197,19 +3196,19 @@ function stripSnapshotIndentation(inlineSnapshot) {
|
|
|
3197
3196
|
return inlineSnapshot;
|
|
3198
3197
|
}
|
|
3199
3198
|
|
|
3200
|
-
var __defProp$
|
|
3201
|
-
var __getOwnPropSymbols$
|
|
3202
|
-
var __hasOwnProp$
|
|
3203
|
-
var __propIsEnum$
|
|
3204
|
-
var __defNormalProp$
|
|
3205
|
-
var __spreadValues$
|
|
3199
|
+
var __defProp$3 = Object.defineProperty;
|
|
3200
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
3201
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
3202
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
3203
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3204
|
+
var __spreadValues$3 = (a, b) => {
|
|
3206
3205
|
for (var prop in b || (b = {}))
|
|
3207
|
-
if (__hasOwnProp$
|
|
3208
|
-
__defNormalProp$
|
|
3209
|
-
if (__getOwnPropSymbols$
|
|
3210
|
-
for (var prop of __getOwnPropSymbols$
|
|
3211
|
-
if (__propIsEnum$
|
|
3212
|
-
__defNormalProp$
|
|
3206
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
3207
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
3208
|
+
if (__getOwnPropSymbols$3)
|
|
3209
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
3210
|
+
if (__propIsEnum$3.call(b, prop))
|
|
3211
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
3213
3212
|
}
|
|
3214
3213
|
return a;
|
|
3215
3214
|
};
|
|
@@ -3229,7 +3228,7 @@ class SnapshotState {
|
|
|
3229
3228
|
this.unmatched = 0;
|
|
3230
3229
|
this._updateSnapshot = options.updateSnapshot;
|
|
3231
3230
|
this.updated = 0;
|
|
3232
|
-
this._snapshotFormat = __spreadValues$
|
|
3231
|
+
this._snapshotFormat = __spreadValues$3({
|
|
3233
3232
|
printBasicPrototype: false
|
|
3234
3233
|
}, options.snapshotFormat);
|
|
3235
3234
|
}
|
|
@@ -3257,7 +3256,7 @@ class SnapshotState {
|
|
|
3257
3256
|
throw new Error(`Vitest: Couldn't infer stack frame for inline snapshot.
|
|
3258
3257
|
${JSON.stringify(stacks)}`);
|
|
3259
3258
|
}
|
|
3260
|
-
this._inlineSnapshots.push(__spreadValues$
|
|
3259
|
+
this._inlineSnapshots.push(__spreadValues$3({
|
|
3261
3260
|
snapshot: receivedSerialized
|
|
3262
3261
|
}, stack));
|
|
3263
3262
|
} else {
|
|
@@ -3375,18 +3374,17 @@ ${JSON.stringify(stacks)}`);
|
|
|
3375
3374
|
}
|
|
3376
3375
|
}
|
|
3377
3376
|
|
|
3378
|
-
const resolveSnapshotPath = (testPath) => index$1.join(index$1.join(index$1.dirname(testPath), "__snapshots__"), `${index$1.basename(testPath)}.snap`);
|
|
3379
3377
|
class SnapshotClient {
|
|
3380
3378
|
constructor() {
|
|
3381
3379
|
this.testFile = "";
|
|
3382
3380
|
}
|
|
3383
|
-
setTest(test) {
|
|
3381
|
+
async setTest(test) {
|
|
3384
3382
|
this.test = test;
|
|
3385
3383
|
if (this.testFile !== this.test.file.filepath) {
|
|
3386
3384
|
if (this.snapshotState)
|
|
3387
3385
|
this.saveSnap();
|
|
3388
3386
|
this.testFile = this.test.file.filepath;
|
|
3389
|
-
this.snapshotState = new SnapshotState(resolveSnapshotPath(this.testFile), getWorkerState().config.snapshotOptions);
|
|
3387
|
+
this.snapshotState = new SnapshotState(await rpc().resolveSnapshotPath(this.testFile), getWorkerState().config.snapshotOptions);
|
|
3390
3388
|
}
|
|
3391
3389
|
}
|
|
3392
3390
|
clearTest() {
|
|
@@ -3514,6 +3512,127 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
3514
3512
|
});
|
|
3515
3513
|
};
|
|
3516
3514
|
|
|
3515
|
+
var __defProp$2 = Object.defineProperty;
|
|
3516
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
3517
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
3518
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
3519
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3520
|
+
var __spreadValues$2 = (a, b) => {
|
|
3521
|
+
for (var prop in b || (b = {}))
|
|
3522
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
3523
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
3524
|
+
if (__getOwnPropSymbols$2)
|
|
3525
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
3526
|
+
if (__propIsEnum$2.call(b, prop))
|
|
3527
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
3528
|
+
}
|
|
3529
|
+
return a;
|
|
3530
|
+
};
|
|
3531
|
+
const EXPECTED_COLOR = c$1.green;
|
|
3532
|
+
const RECEIVED_COLOR = c$1.red;
|
|
3533
|
+
const INVERTED_COLOR = c$1.inverse;
|
|
3534
|
+
const BOLD_WEIGHT = c$1.bold;
|
|
3535
|
+
const DIM_COLOR = c$1.dim;
|
|
3536
|
+
const {
|
|
3537
|
+
AsymmetricMatcher: AsymmetricMatcher$1,
|
|
3538
|
+
DOMCollection,
|
|
3539
|
+
DOMElement,
|
|
3540
|
+
Immutable,
|
|
3541
|
+
ReactElement,
|
|
3542
|
+
ReactTestComponent
|
|
3543
|
+
} = plugins_1;
|
|
3544
|
+
const PLUGINS = [
|
|
3545
|
+
ReactTestComponent,
|
|
3546
|
+
ReactElement,
|
|
3547
|
+
DOMElement,
|
|
3548
|
+
DOMCollection,
|
|
3549
|
+
Immutable,
|
|
3550
|
+
AsymmetricMatcher$1
|
|
3551
|
+
];
|
|
3552
|
+
function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
|
|
3553
|
+
const {
|
|
3554
|
+
comment = "",
|
|
3555
|
+
expectedColor = EXPECTED_COLOR,
|
|
3556
|
+
isDirectExpectCall = false,
|
|
3557
|
+
isNot = false,
|
|
3558
|
+
promise = "",
|
|
3559
|
+
receivedColor = RECEIVED_COLOR,
|
|
3560
|
+
secondArgument = "",
|
|
3561
|
+
secondArgumentColor = EXPECTED_COLOR
|
|
3562
|
+
} = options;
|
|
3563
|
+
let hint = "";
|
|
3564
|
+
let dimString = "expect";
|
|
3565
|
+
if (!isDirectExpectCall && received !== "") {
|
|
3566
|
+
hint += DIM_COLOR(`${dimString}(`) + receivedColor(received);
|
|
3567
|
+
dimString = ")";
|
|
3568
|
+
}
|
|
3569
|
+
if (promise !== "") {
|
|
3570
|
+
hint += DIM_COLOR(`${dimString}.`) + promise;
|
|
3571
|
+
dimString = "";
|
|
3572
|
+
}
|
|
3573
|
+
if (isNot) {
|
|
3574
|
+
hint += `${DIM_COLOR(`${dimString}.`)}not`;
|
|
3575
|
+
dimString = "";
|
|
3576
|
+
}
|
|
3577
|
+
if (matcherName.includes(".")) {
|
|
3578
|
+
dimString += matcherName;
|
|
3579
|
+
} else {
|
|
3580
|
+
hint += DIM_COLOR(`${dimString}.`) + matcherName;
|
|
3581
|
+
dimString = "";
|
|
3582
|
+
}
|
|
3583
|
+
if (expected === "") {
|
|
3584
|
+
dimString += "()";
|
|
3585
|
+
} else {
|
|
3586
|
+
hint += DIM_COLOR(`${dimString}(`) + expectedColor(expected);
|
|
3587
|
+
if (secondArgument)
|
|
3588
|
+
hint += DIM_COLOR(", ") + secondArgumentColor(secondArgument);
|
|
3589
|
+
dimString = ")";
|
|
3590
|
+
}
|
|
3591
|
+
if (comment !== "")
|
|
3592
|
+
dimString += ` // ${comment}`;
|
|
3593
|
+
if (dimString !== "")
|
|
3594
|
+
hint += DIM_COLOR(dimString);
|
|
3595
|
+
return hint;
|
|
3596
|
+
}
|
|
3597
|
+
const SPACE_SYMBOL = "\xB7";
|
|
3598
|
+
const replaceTrailingSpaces = (text) => text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
|
|
3599
|
+
const stringify = (object, maxDepth = 10, options) => {
|
|
3600
|
+
const MAX_LENGTH = 1e4;
|
|
3601
|
+
let result;
|
|
3602
|
+
try {
|
|
3603
|
+
result = format_1(object, __spreadValues$2({
|
|
3604
|
+
maxDepth,
|
|
3605
|
+
plugins: PLUGINS
|
|
3606
|
+
}, options));
|
|
3607
|
+
} catch {
|
|
3608
|
+
result = format_1(object, __spreadValues$2({
|
|
3609
|
+
callToJSON: false,
|
|
3610
|
+
maxDepth,
|
|
3611
|
+
plugins: PLUGINS
|
|
3612
|
+
}, options));
|
|
3613
|
+
}
|
|
3614
|
+
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result;
|
|
3615
|
+
};
|
|
3616
|
+
const printReceived = (object) => RECEIVED_COLOR(replaceTrailingSpaces(stringify(object)));
|
|
3617
|
+
const printExpected = (value) => EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)));
|
|
3618
|
+
function diff(a, b, options) {
|
|
3619
|
+
return unifiedDiff(stringify(a), stringify(b));
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
var matcherUtils = /*#__PURE__*/Object.freeze({
|
|
3623
|
+
__proto__: null,
|
|
3624
|
+
EXPECTED_COLOR: EXPECTED_COLOR,
|
|
3625
|
+
RECEIVED_COLOR: RECEIVED_COLOR,
|
|
3626
|
+
INVERTED_COLOR: INVERTED_COLOR,
|
|
3627
|
+
BOLD_WEIGHT: BOLD_WEIGHT,
|
|
3628
|
+
DIM_COLOR: DIM_COLOR,
|
|
3629
|
+
matcherHint: matcherHint,
|
|
3630
|
+
stringify: stringify,
|
|
3631
|
+
printReceived: printReceived,
|
|
3632
|
+
printExpected: printExpected,
|
|
3633
|
+
diff: diff
|
|
3634
|
+
});
|
|
3635
|
+
|
|
3517
3636
|
const MATCHERS_OBJECT = Symbol.for("matchers-object");
|
|
3518
3637
|
if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
|
|
3519
3638
|
const defaultState = {
|
|
@@ -3684,6 +3803,38 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
3684
3803
|
assertIsMock(assertion);
|
|
3685
3804
|
return assertion._obj;
|
|
3686
3805
|
};
|
|
3806
|
+
const ordinalOf = (i) => {
|
|
3807
|
+
const j = i % 10;
|
|
3808
|
+
const k = i % 100;
|
|
3809
|
+
if (j === 1 && k !== 11)
|
|
3810
|
+
return `${i}st`;
|
|
3811
|
+
if (j === 2 && k !== 12)
|
|
3812
|
+
return `${i}nd`;
|
|
3813
|
+
if (j === 3 && k !== 13)
|
|
3814
|
+
return `${i}rd`;
|
|
3815
|
+
return `${i}th`;
|
|
3816
|
+
};
|
|
3817
|
+
const formatCalls = (spy, msg, actualCall) => {
|
|
3818
|
+
msg += c$1.gray(`
|
|
3819
|
+
|
|
3820
|
+
Received:
|
|
3821
|
+
${spy.mock.calls.map((callArg, i) => {
|
|
3822
|
+
let methodCall = c$1.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
|
|
3823
|
+
|
|
3824
|
+
`);
|
|
3825
|
+
if (actualCall)
|
|
3826
|
+
methodCall += unifiedDiff(stringify(callArg), stringify(actualCall), { showLegend: false });
|
|
3827
|
+
else
|
|
3828
|
+
methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
|
|
3829
|
+
methodCall += "\n";
|
|
3830
|
+
return methodCall;
|
|
3831
|
+
}).join("\n")}`);
|
|
3832
|
+
msg += c$1.gray(`
|
|
3833
|
+
|
|
3834
|
+
Number of calls: ${c$1.bold(spy.mock.calls.length)}
|
|
3835
|
+
`);
|
|
3836
|
+
return msg;
|
|
3837
|
+
};
|
|
3687
3838
|
def(["toHaveBeenCalledTimes", "toBeCalledTimes"], function(number) {
|
|
3688
3839
|
const spy = getSpy(this);
|
|
3689
3840
|
const spyName = spy.getMockName();
|
|
@@ -3700,25 +3851,40 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
3700
3851
|
const spy = getSpy(this);
|
|
3701
3852
|
const spyName = spy.getMockName();
|
|
3702
3853
|
const called = spy.mock.calls.length > 0;
|
|
3703
|
-
|
|
3854
|
+
const isNot = utils.flag(this, "negate");
|
|
3855
|
+
let msg = utils.getMessage(this, [
|
|
3856
|
+
called,
|
|
3857
|
+
`expected "${spyName}" to be called at least once`,
|
|
3858
|
+
`expected "${spyName}" to not be called at all`,
|
|
3859
|
+
true,
|
|
3860
|
+
called
|
|
3861
|
+
]);
|
|
3862
|
+
if (called && isNot)
|
|
3863
|
+
msg += formatCalls(spy, msg);
|
|
3864
|
+
if (called && isNot || !called && !isNot) {
|
|
3865
|
+
const err = new Error(msg);
|
|
3866
|
+
err.name = "AssertionError";
|
|
3867
|
+
throw err;
|
|
3868
|
+
}
|
|
3704
3869
|
});
|
|
3705
3870
|
def(["toHaveBeenCalledWith", "toBeCalledWith"], function(...args) {
|
|
3706
3871
|
const spy = getSpy(this);
|
|
3707
3872
|
const spyName = spy.getMockName();
|
|
3708
3873
|
const pass = spy.mock.calls.some((callArg) => equals(callArg, args, [iterableEquality]));
|
|
3709
|
-
|
|
3874
|
+
const isNot = utils.flag(this, "negate");
|
|
3875
|
+
let msg = utils.getMessage(this, [
|
|
3876
|
+
pass,
|
|
3877
|
+
`expected "${spyName}" to be called with arguments: #{exp}`,
|
|
3878
|
+
`expected "${spyName}" to not be called with arguments: #{exp}`,
|
|
3879
|
+
args
|
|
3880
|
+
]);
|
|
3881
|
+
if (pass && isNot || !pass && !isNot) {
|
|
3882
|
+
msg += formatCalls(spy, msg, args);
|
|
3883
|
+
const err = new Error(msg);
|
|
3884
|
+
err.name = "AssertionError";
|
|
3885
|
+
throw err;
|
|
3886
|
+
}
|
|
3710
3887
|
});
|
|
3711
|
-
const ordinalOf = (i) => {
|
|
3712
|
-
const j = i % 10;
|
|
3713
|
-
const k = i % 100;
|
|
3714
|
-
if (j === 1 && k !== 11)
|
|
3715
|
-
return `${i}st`;
|
|
3716
|
-
if (j === 2 && k !== 12)
|
|
3717
|
-
return `${i}nd`;
|
|
3718
|
-
if (j === 3 && k !== 13)
|
|
3719
|
-
return `${i}rd`;
|
|
3720
|
-
return `${i}th`;
|
|
3721
|
-
};
|
|
3722
3888
|
def(["toHaveBeenNthCalledWith", "nthCalledWith"], function(times, ...args) {
|
|
3723
3889
|
const spy = getSpy(this);
|
|
3724
3890
|
const spyName = spy.getMockName();
|
|
@@ -3859,111 +4025,6 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
3859
4025
|
utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
|
|
3860
4026
|
};
|
|
3861
4027
|
|
|
3862
|
-
const EXPECTED_COLOR = c$1.green;
|
|
3863
|
-
const RECEIVED_COLOR = c$1.red;
|
|
3864
|
-
const INVERTED_COLOR = c$1.inverse;
|
|
3865
|
-
const BOLD_WEIGHT = c$1.bold;
|
|
3866
|
-
const DIM_COLOR = c$1.dim;
|
|
3867
|
-
const {
|
|
3868
|
-
AsymmetricMatcher: AsymmetricMatcher$1,
|
|
3869
|
-
DOMCollection,
|
|
3870
|
-
DOMElement,
|
|
3871
|
-
Immutable,
|
|
3872
|
-
ReactElement,
|
|
3873
|
-
ReactTestComponent
|
|
3874
|
-
} = plugins_1;
|
|
3875
|
-
const PLUGINS = [
|
|
3876
|
-
ReactTestComponent,
|
|
3877
|
-
ReactElement,
|
|
3878
|
-
DOMElement,
|
|
3879
|
-
DOMCollection,
|
|
3880
|
-
Immutable,
|
|
3881
|
-
AsymmetricMatcher$1
|
|
3882
|
-
];
|
|
3883
|
-
function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
|
|
3884
|
-
const {
|
|
3885
|
-
comment = "",
|
|
3886
|
-
expectedColor = EXPECTED_COLOR,
|
|
3887
|
-
isDirectExpectCall = false,
|
|
3888
|
-
isNot = false,
|
|
3889
|
-
promise = "",
|
|
3890
|
-
receivedColor = RECEIVED_COLOR,
|
|
3891
|
-
secondArgument = "",
|
|
3892
|
-
secondArgumentColor = EXPECTED_COLOR
|
|
3893
|
-
} = options;
|
|
3894
|
-
let hint = "";
|
|
3895
|
-
let dimString = "expect";
|
|
3896
|
-
if (!isDirectExpectCall && received !== "") {
|
|
3897
|
-
hint += DIM_COLOR(`${dimString}(`) + receivedColor(received);
|
|
3898
|
-
dimString = ")";
|
|
3899
|
-
}
|
|
3900
|
-
if (promise !== "") {
|
|
3901
|
-
hint += DIM_COLOR(`${dimString}.`) + promise;
|
|
3902
|
-
dimString = "";
|
|
3903
|
-
}
|
|
3904
|
-
if (isNot) {
|
|
3905
|
-
hint += `${DIM_COLOR(`${dimString}.`)}not`;
|
|
3906
|
-
dimString = "";
|
|
3907
|
-
}
|
|
3908
|
-
if (matcherName.includes(".")) {
|
|
3909
|
-
dimString += matcherName;
|
|
3910
|
-
} else {
|
|
3911
|
-
hint += DIM_COLOR(`${dimString}.`) + matcherName;
|
|
3912
|
-
dimString = "";
|
|
3913
|
-
}
|
|
3914
|
-
if (expected === "") {
|
|
3915
|
-
dimString += "()";
|
|
3916
|
-
} else {
|
|
3917
|
-
hint += DIM_COLOR(`${dimString}(`) + expectedColor(expected);
|
|
3918
|
-
if (secondArgument)
|
|
3919
|
-
hint += DIM_COLOR(", ") + secondArgumentColor(secondArgument);
|
|
3920
|
-
dimString = ")";
|
|
3921
|
-
}
|
|
3922
|
-
if (comment !== "")
|
|
3923
|
-
dimString += ` // ${comment}`;
|
|
3924
|
-
if (dimString !== "")
|
|
3925
|
-
hint += DIM_COLOR(dimString);
|
|
3926
|
-
return hint;
|
|
3927
|
-
}
|
|
3928
|
-
const SPACE_SYMBOL = "\xB7";
|
|
3929
|
-
const replaceTrailingSpaces = (text) => text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
|
|
3930
|
-
const stringify = (object, maxDepth = 10) => {
|
|
3931
|
-
const MAX_LENGTH = 1e4;
|
|
3932
|
-
let result;
|
|
3933
|
-
try {
|
|
3934
|
-
result = format_1(object, {
|
|
3935
|
-
maxDepth,
|
|
3936
|
-
plugins: PLUGINS
|
|
3937
|
-
});
|
|
3938
|
-
} catch {
|
|
3939
|
-
result = format_1(object, {
|
|
3940
|
-
callToJSON: false,
|
|
3941
|
-
maxDepth,
|
|
3942
|
-
plugins: PLUGINS
|
|
3943
|
-
});
|
|
3944
|
-
}
|
|
3945
|
-
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result;
|
|
3946
|
-
};
|
|
3947
|
-
const printReceived = (object) => RECEIVED_COLOR(replaceTrailingSpaces(stringify(object)));
|
|
3948
|
-
const printExpected = (value) => EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)));
|
|
3949
|
-
function diff(a, b, options) {
|
|
3950
|
-
return unifiedDiff(stringify(a), stringify(b));
|
|
3951
|
-
}
|
|
3952
|
-
|
|
3953
|
-
var matcherUtils = /*#__PURE__*/Object.freeze({
|
|
3954
|
-
__proto__: null,
|
|
3955
|
-
EXPECTED_COLOR: EXPECTED_COLOR,
|
|
3956
|
-
RECEIVED_COLOR: RECEIVED_COLOR,
|
|
3957
|
-
INVERTED_COLOR: INVERTED_COLOR,
|
|
3958
|
-
BOLD_WEIGHT: BOLD_WEIGHT,
|
|
3959
|
-
DIM_COLOR: DIM_COLOR,
|
|
3960
|
-
matcherHint: matcherHint,
|
|
3961
|
-
stringify: stringify,
|
|
3962
|
-
printReceived: printReceived,
|
|
3963
|
-
printExpected: printExpected,
|
|
3964
|
-
diff: diff
|
|
3965
|
-
});
|
|
3966
|
-
|
|
3967
4028
|
var __defProp$1 = Object.defineProperty;
|
|
3968
4029
|
var __defProps$1 = Object.defineProperties;
|
|
3969
4030
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
@@ -7033,6 +7094,10 @@ class VitestUtils {
|
|
|
7033
7094
|
globalThis.window[name] = value;
|
|
7034
7095
|
return this;
|
|
7035
7096
|
}
|
|
7097
|
+
resetModules() {
|
|
7098
|
+
resetModules();
|
|
7099
|
+
return this;
|
|
7100
|
+
}
|
|
7036
7101
|
}
|
|
7037
7102
|
const vitest = new VitestUtils();
|
|
7038
7103
|
const vi = vitest;
|
|
@@ -7060,10 +7125,6 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
7060
7125
|
should: should,
|
|
7061
7126
|
chai: chai$1,
|
|
7062
7127
|
expect: expect,
|
|
7063
|
-
spies: spies,
|
|
7064
|
-
isMockFunction: isMockFunction,
|
|
7065
|
-
spyOn: spyOn,
|
|
7066
|
-
fn: fn,
|
|
7067
7128
|
vitest: vitest,
|
|
7068
7129
|
vi: vi,
|
|
7069
7130
|
getRunningMode: getRunningMode,
|