vitest 0.27.2 → 0.28.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/LICENSE.md +4 -93
- package/browser.d.ts +1 -1
- package/dist/browser.d.ts +11 -13
- package/dist/browser.js +10 -34
- package/dist/{chunk-api-setup.029198e3.js → chunk-api-setup.52751a38.js} +27 -12
- package/dist/chunk-constants.797d3ebf.js +42 -0
- package/dist/{chunk-env-node.787e9561.js → chunk-env-node.ffd1183b.js} +26 -0
- package/dist/{chunk-install-pkg.7b006b3e.js → chunk-install-pkg.cfd23146.js} +51 -11
- package/dist/chunk-integrations-coverage.48e6286b.js +3993 -0
- package/dist/chunk-integrations-globals.0d5f50f0.js +29 -0
- package/dist/chunk-integrations-run-once.38756e30.js +27 -0
- package/dist/chunk-integrations-utils.f1f6f1ed.js +118 -0
- package/dist/{chunk-node-git.125c9008.js → chunk-node-git.d9ad64ab.js} +6 -7
- package/dist/{chunk-snapshot-manager.ce714e21.js → chunk-node-pkg.dcdf4369.js} +12653 -9324
- package/dist/{chunk-runtime-mocker.58511c38.js → chunk-runtime-mocker.03017e8c.js} +14 -13
- package/dist/{chunk-runtime-rpc.d709e91b.js → chunk-runtime-rpc.9c0386cc.js} +3 -2
- package/dist/chunk-runtime-setup.d9302cfd.js +20 -0
- package/dist/chunk-snapshot-env.6457638e.js +11 -0
- package/dist/chunk-utils-base.977ae74f.js +77 -0
- package/dist/chunk-utils-env.860d90c2.js +6 -0
- package/dist/chunk-utils-global.442d1d33.js +73 -0
- package/dist/{chunk-utils-import.054ab315.js → chunk-utils-import.9911c99d.js} +3289 -169
- package/dist/chunk-utils-tasks.1b603032.js +103 -0
- package/dist/cli-wrapper.js +8 -6
- package/dist/cli.js +18 -15
- package/dist/config.cjs +10 -7
- package/dist/config.d.ts +22 -4
- package/dist/config.js +10 -8
- package/dist/entry.js +244 -28
- package/dist/env-afee91f0.d.ts +10 -0
- package/dist/environments.d.ts +7 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +160 -11
- package/dist/index.js +18 -18
- package/dist/loader.js +9 -8
- package/dist/node.d.ts +9 -7
- package/dist/node.js +20 -17
- package/dist/runners-chunk.js +215 -0
- package/dist/runners.d.ts +39 -0
- package/dist/runners.js +18 -0
- package/dist/spy.js +1 -2
- package/dist/suite.d.ts +2 -0
- package/dist/suite.js +2 -18
- package/dist/{types-d97c72c7.d.ts → types-c800444e.d.ts} +196 -437
- package/dist/{vendor-index.e6c27006.js → vendor-index.618ca5a1.js} +1078 -10
- package/dist/{vendor-index.b0346fe4.js → vendor-index.bdee400f.js} +1 -0
- package/dist/worker.js +17 -16
- package/package.json +22 -12
- package/runners.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/dist/chunk-integrations-coverage.44413252.js +0 -240
- package/dist/chunk-integrations-globals.0024ce21.js +0 -27
- package/dist/chunk-mock-date.c543fa3e.js +0 -349
- package/dist/chunk-runtime-chain.2da9e75c.js +0 -2595
- package/dist/chunk-runtime-error.de671af0.js +0 -144
- package/dist/chunk-runtime-setup.35da9209.js +0 -649
- package/dist/chunk-utils-env.f4a39d2c.js +0 -228
- package/dist/chunk-utils-source-map.5f5d12cf.js +0 -408
- package/dist/chunk-utils-timers.52534f96.js +0 -3573
- package/dist/index-50755efe.d.ts +0 -258
- package/dist/vendor-index.451e37bc.js +0 -1071
- package/dist/vendor-index.723a074f.js +0 -102
- package/dist/vendor-index.9c919048.js +0 -61
- package/dist/vendor-index.9f20a9be.js +0 -6291
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import util$1 from 'util';
|
|
2
|
-
import { util } from 'chai';
|
|
3
|
-
import { a as stringify } from './chunk-utils-timers.52534f96.js';
|
|
4
|
-
import { w as deepClone, g as getWorkerState, x as getType } from './chunk-mock-date.c543fa3e.js';
|
|
5
|
-
|
|
6
|
-
const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
|
|
7
|
-
const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
|
|
8
|
-
const isImmutable = (v) => v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]);
|
|
9
|
-
const OBJECT_PROTO = Object.getPrototypeOf({});
|
|
10
|
-
function getUnserializableMessage(err) {
|
|
11
|
-
if (err instanceof Error)
|
|
12
|
-
return `<unserializable>: ${err.message}`;
|
|
13
|
-
if (typeof err === "string")
|
|
14
|
-
return `<unserializable>: ${err}`;
|
|
15
|
-
return "<unserializable>";
|
|
16
|
-
}
|
|
17
|
-
function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
18
|
-
if (!val || typeof val === "string")
|
|
19
|
-
return val;
|
|
20
|
-
if (typeof val === "function")
|
|
21
|
-
return `Function<${val.name || "anonymous"}>`;
|
|
22
|
-
if (typeof val === "symbol")
|
|
23
|
-
return val.toString();
|
|
24
|
-
if (typeof val !== "object")
|
|
25
|
-
return val;
|
|
26
|
-
if (isImmutable(val))
|
|
27
|
-
return serializeError(val.toJSON(), seen);
|
|
28
|
-
if (val instanceof Promise || val.constructor && val.constructor.prototype === "AsyncFunction")
|
|
29
|
-
return "Promise";
|
|
30
|
-
if (typeof Element !== "undefined" && val instanceof Element)
|
|
31
|
-
return val.tagName;
|
|
32
|
-
if (typeof val.asymmetricMatch === "function")
|
|
33
|
-
return `${val.toString()} ${util$1.format(val.sample)}`;
|
|
34
|
-
if (seen.has(val))
|
|
35
|
-
return seen.get(val);
|
|
36
|
-
if (Array.isArray(val)) {
|
|
37
|
-
const clone = new Array(val.length);
|
|
38
|
-
seen.set(val, clone);
|
|
39
|
-
val.forEach((e, i) => {
|
|
40
|
-
try {
|
|
41
|
-
clone[i] = serializeError(e, seen);
|
|
42
|
-
} catch (err) {
|
|
43
|
-
clone[i] = getUnserializableMessage(err);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return clone;
|
|
47
|
-
} else {
|
|
48
|
-
const clone = /* @__PURE__ */ Object.create(null);
|
|
49
|
-
seen.set(val, clone);
|
|
50
|
-
let obj = val;
|
|
51
|
-
while (obj && obj !== OBJECT_PROTO) {
|
|
52
|
-
Object.getOwnPropertyNames(obj).forEach((key) => {
|
|
53
|
-
if (key in clone)
|
|
54
|
-
return;
|
|
55
|
-
try {
|
|
56
|
-
clone[key] = serializeError(val[key], seen);
|
|
57
|
-
} catch (err) {
|
|
58
|
-
delete clone[key];
|
|
59
|
-
clone[key] = getUnserializableMessage(err);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
obj = Object.getPrototypeOf(obj);
|
|
63
|
-
}
|
|
64
|
-
return clone;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function normalizeErrorMessage(message) {
|
|
68
|
-
return message.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
69
|
-
}
|
|
70
|
-
function processError(err) {
|
|
71
|
-
if (!err || typeof err !== "object")
|
|
72
|
-
return err;
|
|
73
|
-
if (err.stack)
|
|
74
|
-
err.stackStr = String(err.stack);
|
|
75
|
-
if (err.name)
|
|
76
|
-
err.nameStr = String(err.name);
|
|
77
|
-
const clonedActual = deepClone(err.actual);
|
|
78
|
-
const clonedExpected = deepClone(err.expected);
|
|
79
|
-
const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected);
|
|
80
|
-
err.actual = replacedActual;
|
|
81
|
-
err.expected = replacedExpected;
|
|
82
|
-
const workerState = getWorkerState();
|
|
83
|
-
const maxDiffSize = workerState.config.outputDiffMaxSize;
|
|
84
|
-
if (typeof err.expected !== "string")
|
|
85
|
-
err.expected = stringify(err.expected, 10, { maxLength: maxDiffSize });
|
|
86
|
-
if (typeof err.actual !== "string")
|
|
87
|
-
err.actual = stringify(err.actual, 10, { maxLength: maxDiffSize });
|
|
88
|
-
try {
|
|
89
|
-
if (typeof err.message === "string")
|
|
90
|
-
err.message = normalizeErrorMessage(err.message);
|
|
91
|
-
if (typeof err.cause === "object" && typeof err.cause.message === "string")
|
|
92
|
-
err.cause.message = normalizeErrorMessage(err.cause.message);
|
|
93
|
-
} catch {
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
return serializeError(err);
|
|
97
|
-
} catch (e) {
|
|
98
|
-
return serializeError(new Error(`Failed to fully serialize error: ${e == null ? void 0 : e.message}
|
|
99
|
-
Inner error message: ${err == null ? void 0 : err.message}`));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function isAsymmetricMatcher(data) {
|
|
103
|
-
const type = getType(data);
|
|
104
|
-
return type === "Object" && typeof data.asymmetricMatch === "function";
|
|
105
|
-
}
|
|
106
|
-
function isReplaceable(obj1, obj2) {
|
|
107
|
-
const obj1Type = getType(obj1);
|
|
108
|
-
const obj2Type = getType(obj2);
|
|
109
|
-
return obj1Type === obj2Type && obj1Type === "Object";
|
|
110
|
-
}
|
|
111
|
-
function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE__ */ new WeakSet(), expectedReplaced = /* @__PURE__ */ new WeakSet()) {
|
|
112
|
-
if (!isReplaceable(actual, expected))
|
|
113
|
-
return { replacedActual: actual, replacedExpected: expected };
|
|
114
|
-
if (actualReplaced.has(actual) || expectedReplaced.has(expected))
|
|
115
|
-
return { replacedActual: actual, replacedExpected: expected };
|
|
116
|
-
actualReplaced.add(actual);
|
|
117
|
-
expectedReplaced.add(expected);
|
|
118
|
-
util.getOwnEnumerableProperties(expected).forEach((key) => {
|
|
119
|
-
const expectedValue = expected[key];
|
|
120
|
-
const actualValue = actual[key];
|
|
121
|
-
if (isAsymmetricMatcher(expectedValue)) {
|
|
122
|
-
if (expectedValue.asymmetricMatch(actualValue))
|
|
123
|
-
actual[key] = expectedValue;
|
|
124
|
-
} else if (isAsymmetricMatcher(actualValue)) {
|
|
125
|
-
if (actualValue.asymmetricMatch(expectedValue))
|
|
126
|
-
expected[key] = actualValue;
|
|
127
|
-
} else if (isReplaceable(actualValue, expectedValue)) {
|
|
128
|
-
const replaced = replaceAsymmetricMatcher(
|
|
129
|
-
actualValue,
|
|
130
|
-
expectedValue,
|
|
131
|
-
actualReplaced,
|
|
132
|
-
expectedReplaced
|
|
133
|
-
);
|
|
134
|
-
actual[key] = replaced.replacedActual;
|
|
135
|
-
expected[key] = replaced.replacedExpected;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
return {
|
|
139
|
-
replacedActual: actual,
|
|
140
|
-
replacedExpected: expected
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export { processError as p };
|