vitest 0.0.107 → 0.0.111
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/_commonjsHelpers-c9e3b764.js +11 -0
- package/dist/cli.js +8 -9
- package/dist/{constants-82dad049.js → constants-2b0310b7.js} +1 -1
- package/dist/{error-e81aa23d.js → diff-66d6bb83.js} +51 -41
- package/dist/entry.js +37 -456
- package/dist/global-201fd559.js +20 -0
- package/dist/{index-77f19d39.js → index-2bb9fd4d.js} +12 -5
- package/dist/{index-84978a77.js → index-61c8686f.js} +1 -1
- package/dist/{index-8cc284f9.js → index-8ab26d25.js} +1768 -1563
- package/dist/{index-1ede1cc5.js → index-9f4b9905.js} +2 -6
- package/dist/index.d.ts +178 -19
- package/dist/index.js +6 -5
- package/dist/jest-mock-a57b745c.js +101 -0
- package/dist/{middleware-0c8d46aa.js → middleware-2028dfa0.js} +2 -4
- package/dist/node.d.ts +62 -1
- package/dist/node.js +6 -7
- package/dist/utils-cb6b1266.js +352 -0
- package/dist/utils.js +1 -3
- package/dist/vi-cb9e4e4e.js +1018 -0
- package/dist/worker.js +142 -72
- package/package.json +6 -6
- package/dist/global-0f4da031.js +0 -19
- package/dist/index-9e71c815.js +0 -12
- package/dist/suite-ff89a82e.js +0 -201
- package/dist/utils-92ec89d1.js +0 -814
package/dist/entry.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import fs, { promises } from 'fs';
|
|
2
|
-
import {
|
|
2
|
+
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-cb9e4e4e.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
6
|
import chai$1, { expect, util } from 'chai';
|
|
7
|
+
import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
|
|
8
|
+
import { l as index, o as getNames, c as c$1, t as toArray, r as relative, p as interpretOnlyMode, q as partitionSuiteChildren, u as hasTests, j as hasFailed } from './utils-cb6b1266.js';
|
|
7
9
|
import { r as rpc, s as send } from './rpc-7de86f29.js';
|
|
8
|
-
import { u as unifiedDiff } from './
|
|
10
|
+
import { u as unifiedDiff } from './diff-66d6bb83.js';
|
|
9
11
|
import { performance } from 'perf_hooks';
|
|
10
|
-
import {
|
|
11
|
-
import { n as nanoid } from './index-9e71c815.js';
|
|
12
|
+
import { n as nanoid } from './jest-mock-a57b745c.js';
|
|
12
13
|
import { format as format$1 } from 'util';
|
|
13
14
|
import 'tty';
|
|
14
15
|
import 'path';
|
|
@@ -1421,13 +1422,13 @@ var _collections$1 = collections;
|
|
|
1421
1422
|
// SENTINEL constants are from https://github.com/facebook/immutable-js
|
|
1422
1423
|
const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
|
|
1423
1424
|
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
|
1424
|
-
const IS_KEYED_SENTINEL
|
|
1425
|
+
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
|
|
1425
1426
|
const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
|
|
1426
|
-
const IS_ORDERED_SENTINEL
|
|
1427
|
+
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
|
|
1427
1428
|
const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
|
|
1428
1429
|
|
|
1429
1430
|
const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
|
|
1430
|
-
const IS_SET_SENTINEL
|
|
1431
|
+
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
|
1431
1432
|
const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
|
|
1432
1433
|
|
|
1433
1434
|
const getImmutableName = name => 'Immutable.' + name;
|
|
@@ -1516,7 +1517,7 @@ const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
|
|
|
1516
1517
|
return printAsLeaf(name);
|
|
1517
1518
|
}
|
|
1518
1519
|
|
|
1519
|
-
if (val[IS_KEYED_SENTINEL
|
|
1520
|
+
if (val[IS_KEYED_SENTINEL]) {
|
|
1520
1521
|
return (
|
|
1521
1522
|
name +
|
|
1522
1523
|
SPACE +
|
|
@@ -1589,7 +1590,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1589
1590
|
depth,
|
|
1590
1591
|
refs,
|
|
1591
1592
|
printer,
|
|
1592
|
-
val[IS_ORDERED_SENTINEL
|
|
1593
|
+
val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
|
|
1593
1594
|
);
|
|
1594
1595
|
}
|
|
1595
1596
|
|
|
@@ -1605,7 +1606,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1605
1606
|
);
|
|
1606
1607
|
}
|
|
1607
1608
|
|
|
1608
|
-
if (val[IS_SET_SENTINEL
|
|
1609
|
+
if (val[IS_SET_SENTINEL]) {
|
|
1609
1610
|
return printImmutableValues(
|
|
1610
1611
|
val,
|
|
1611
1612
|
config,
|
|
@@ -1613,7 +1614,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1613
1614
|
depth,
|
|
1614
1615
|
refs,
|
|
1615
1616
|
printer,
|
|
1616
|
-
val[IS_ORDERED_SENTINEL
|
|
1617
|
+
val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
|
|
1617
1618
|
);
|
|
1618
1619
|
}
|
|
1619
1620
|
|
|
@@ -2186,7 +2187,7 @@ function _interopRequireDefault(obj) {
|
|
|
2186
2187
|
*/
|
|
2187
2188
|
|
|
2188
2189
|
/* eslint-disable local/ban-types-eventually */
|
|
2189
|
-
const toString
|
|
2190
|
+
const toString = Object.prototype.toString;
|
|
2190
2191
|
const toISOString = Date.prototype.toISOString;
|
|
2191
2192
|
const errorToString = Error.prototype.toString;
|
|
2192
2193
|
const regExpToString = RegExp.prototype.toString;
|
|
@@ -2298,7 +2299,7 @@ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
|
2298
2299
|
return printSymbol(val);
|
|
2299
2300
|
}
|
|
2300
2301
|
|
|
2301
|
-
const toStringed = toString
|
|
2302
|
+
const toStringed = toString.call(val);
|
|
2302
2303
|
|
|
2303
2304
|
if (toStringed === '[object WeakMap]') {
|
|
2304
2305
|
return 'WeakMap {}';
|
|
@@ -2374,7 +2375,7 @@ function printComplexValue(
|
|
|
2374
2375
|
return printer(val.toJSON(), config, indentation, depth, refs, true);
|
|
2375
2376
|
}
|
|
2376
2377
|
|
|
2377
|
-
const toStringed = toString
|
|
2378
|
+
const toStringed = toString.call(val);
|
|
2378
2379
|
|
|
2379
2380
|
if (toStringed === '[object Arguments]') {
|
|
2380
2381
|
return hitMaxDepth
|
|
@@ -3168,14 +3169,12 @@ const stringify = (object, maxDepth = 10) => {
|
|
|
3168
3169
|
try {
|
|
3169
3170
|
result = format_1(object, {
|
|
3170
3171
|
maxDepth,
|
|
3171
|
-
min: true,
|
|
3172
3172
|
plugins: PLUGINS
|
|
3173
3173
|
});
|
|
3174
3174
|
} catch {
|
|
3175
3175
|
result = format_1(object, {
|
|
3176
3176
|
callToJSON: false,
|
|
3177
3177
|
maxDepth,
|
|
3178
|
-
min: true,
|
|
3179
3178
|
plugins: PLUGINS
|
|
3180
3179
|
});
|
|
3181
3180
|
}
|
|
@@ -3201,238 +3200,6 @@ var matcherUtils = /*#__PURE__*/Object.freeze({
|
|
|
3201
3200
|
diff: diff
|
|
3202
3201
|
});
|
|
3203
3202
|
|
|
3204
|
-
const isObject = (val) => toString.call(val) === "[object Object]";
|
|
3205
|
-
function equals(a, b, customTesters, strictCheck) {
|
|
3206
|
-
customTesters = customTesters || [];
|
|
3207
|
-
return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey);
|
|
3208
|
-
}
|
|
3209
|
-
function isAsymmetric(obj) {
|
|
3210
|
-
return !!obj && isA("Function", obj.asymmetricMatch);
|
|
3211
|
-
}
|
|
3212
|
-
function hasAsymmetric(obj, seen = /* @__PURE__ */ new Set()) {
|
|
3213
|
-
if (seen.has(obj))
|
|
3214
|
-
return false;
|
|
3215
|
-
seen.add(obj);
|
|
3216
|
-
if (isAsymmetric(obj))
|
|
3217
|
-
return true;
|
|
3218
|
-
if (Array.isArray(obj))
|
|
3219
|
-
return obj.some((i) => hasAsymmetric(i, seen));
|
|
3220
|
-
if (obj instanceof Set)
|
|
3221
|
-
return Array.from(obj).some((i) => hasAsymmetric(i, seen));
|
|
3222
|
-
if (isObject(obj))
|
|
3223
|
-
return Object.values(obj).some((v) => hasAsymmetric(v, seen));
|
|
3224
|
-
return false;
|
|
3225
|
-
}
|
|
3226
|
-
function asymmetricMatch(a, b) {
|
|
3227
|
-
const asymmetricA = isAsymmetric(a);
|
|
3228
|
-
const asymmetricB = isAsymmetric(b);
|
|
3229
|
-
if (asymmetricA && asymmetricB)
|
|
3230
|
-
return void 0;
|
|
3231
|
-
if (asymmetricA)
|
|
3232
|
-
return a.asymmetricMatch(b);
|
|
3233
|
-
if (asymmetricB)
|
|
3234
|
-
return b.asymmetricMatch(a);
|
|
3235
|
-
}
|
|
3236
|
-
function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
3237
|
-
let result = true;
|
|
3238
|
-
const asymmetricResult = asymmetricMatch(a, b);
|
|
3239
|
-
if (asymmetricResult !== void 0)
|
|
3240
|
-
return asymmetricResult;
|
|
3241
|
-
for (let i = 0; i < customTesters.length; i++) {
|
|
3242
|
-
const customTesterResult = customTesters[i](a, b);
|
|
3243
|
-
if (customTesterResult !== void 0)
|
|
3244
|
-
return customTesterResult;
|
|
3245
|
-
}
|
|
3246
|
-
if (a instanceof Error && b instanceof Error)
|
|
3247
|
-
return a.message === b.message;
|
|
3248
|
-
if (Object.is(a, b))
|
|
3249
|
-
return true;
|
|
3250
|
-
if (a === null || b === null)
|
|
3251
|
-
return a === b;
|
|
3252
|
-
const className = Object.prototype.toString.call(a);
|
|
3253
|
-
if (className !== Object.prototype.toString.call(b))
|
|
3254
|
-
return false;
|
|
3255
|
-
switch (className) {
|
|
3256
|
-
case "[object Boolean]":
|
|
3257
|
-
case "[object String]":
|
|
3258
|
-
case "[object Number]":
|
|
3259
|
-
if (typeof a !== typeof b) {
|
|
3260
|
-
return false;
|
|
3261
|
-
} else if (typeof a !== "object" && typeof b !== "object") {
|
|
3262
|
-
return Object.is(a, b);
|
|
3263
|
-
} else {
|
|
3264
|
-
return Object.is(a.valueOf(), b.valueOf());
|
|
3265
|
-
}
|
|
3266
|
-
case "[object Date]":
|
|
3267
|
-
return +a === +b;
|
|
3268
|
-
case "[object RegExp]":
|
|
3269
|
-
return a.source === b.source && a.flags === b.flags;
|
|
3270
|
-
}
|
|
3271
|
-
if (typeof a !== "object" || typeof b !== "object")
|
|
3272
|
-
return false;
|
|
3273
|
-
if (isDomNode(a) && isDomNode(b))
|
|
3274
|
-
return a.isEqualNode(b);
|
|
3275
|
-
let length = aStack.length;
|
|
3276
|
-
while (length--) {
|
|
3277
|
-
if (aStack[length] === a)
|
|
3278
|
-
return bStack[length] === b;
|
|
3279
|
-
else if (bStack[length] === b)
|
|
3280
|
-
return false;
|
|
3281
|
-
}
|
|
3282
|
-
aStack.push(a);
|
|
3283
|
-
bStack.push(b);
|
|
3284
|
-
if (className === "[object Array]" && a.length !== b.length)
|
|
3285
|
-
return false;
|
|
3286
|
-
const aKeys = keys(a, hasKey2);
|
|
3287
|
-
let key;
|
|
3288
|
-
let size = aKeys.length;
|
|
3289
|
-
if (keys(b, hasKey2).length !== size)
|
|
3290
|
-
return false;
|
|
3291
|
-
while (size--) {
|
|
3292
|
-
key = aKeys[size];
|
|
3293
|
-
result = hasKey2(b, key) && eq(a[key], b[key], aStack, bStack, customTesters, hasKey2);
|
|
3294
|
-
if (!result)
|
|
3295
|
-
return false;
|
|
3296
|
-
}
|
|
3297
|
-
aStack.pop();
|
|
3298
|
-
bStack.pop();
|
|
3299
|
-
return result;
|
|
3300
|
-
}
|
|
3301
|
-
function keys(obj, hasKey2) {
|
|
3302
|
-
const keys2 = [];
|
|
3303
|
-
for (const key in obj) {
|
|
3304
|
-
if (hasKey2(obj, key))
|
|
3305
|
-
keys2.push(key);
|
|
3306
|
-
}
|
|
3307
|
-
return keys2.concat(Object.getOwnPropertySymbols(obj).filter((symbol) => Object.getOwnPropertyDescriptor(obj, symbol).enumerable));
|
|
3308
|
-
}
|
|
3309
|
-
function hasDefinedKey(obj, key) {
|
|
3310
|
-
return hasKey(obj, key) && obj[key] !== void 0;
|
|
3311
|
-
}
|
|
3312
|
-
function hasKey(obj, key) {
|
|
3313
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
3314
|
-
}
|
|
3315
|
-
function isA(typeName, value) {
|
|
3316
|
-
return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
|
|
3317
|
-
}
|
|
3318
|
-
function isDomNode(obj) {
|
|
3319
|
-
return obj !== null && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string" && typeof obj.isEqualNode === "function";
|
|
3320
|
-
}
|
|
3321
|
-
const IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
|
|
3322
|
-
const IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
|
|
3323
|
-
const IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
|
|
3324
|
-
function isImmutableUnorderedKeyed(maybeKeyed) {
|
|
3325
|
-
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL] && !maybeKeyed[IS_ORDERED_SENTINEL]);
|
|
3326
|
-
}
|
|
3327
|
-
function isImmutableUnorderedSet(maybeSet) {
|
|
3328
|
-
return !!(maybeSet && maybeSet[IS_SET_SENTINEL] && !maybeSet[IS_ORDERED_SENTINEL]);
|
|
3329
|
-
}
|
|
3330
|
-
const IteratorSymbol = Symbol.iterator;
|
|
3331
|
-
const hasIterator = (object) => !!(object != null && object[IteratorSymbol]);
|
|
3332
|
-
const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
|
3333
|
-
if (typeof a !== "object" || typeof b !== "object" || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b))
|
|
3334
|
-
return void 0;
|
|
3335
|
-
if (a.constructor !== b.constructor)
|
|
3336
|
-
return false;
|
|
3337
|
-
let length = aStack.length;
|
|
3338
|
-
while (length--) {
|
|
3339
|
-
if (aStack[length] === a)
|
|
3340
|
-
return bStack[length] === b;
|
|
3341
|
-
}
|
|
3342
|
-
aStack.push(a);
|
|
3343
|
-
bStack.push(b);
|
|
3344
|
-
const iterableEqualityWithStack = (a2, b2) => iterableEquality(a2, b2, [...aStack], [...bStack]);
|
|
3345
|
-
if (a.size !== void 0) {
|
|
3346
|
-
if (a.size !== b.size) {
|
|
3347
|
-
return false;
|
|
3348
|
-
} else if (isA("Set", a) || isImmutableUnorderedSet(a)) {
|
|
3349
|
-
let allFound = true;
|
|
3350
|
-
for (const aValue of a) {
|
|
3351
|
-
if (!b.has(aValue)) {
|
|
3352
|
-
let has = false;
|
|
3353
|
-
for (const bValue of b) {
|
|
3354
|
-
const isEqual = equals(aValue, bValue, [iterableEqualityWithStack]);
|
|
3355
|
-
if (isEqual === true)
|
|
3356
|
-
has = true;
|
|
3357
|
-
}
|
|
3358
|
-
if (has === false) {
|
|
3359
|
-
allFound = false;
|
|
3360
|
-
break;
|
|
3361
|
-
}
|
|
3362
|
-
}
|
|
3363
|
-
}
|
|
3364
|
-
aStack.pop();
|
|
3365
|
-
bStack.pop();
|
|
3366
|
-
return allFound;
|
|
3367
|
-
} else if (isA("Map", a) || isImmutableUnorderedKeyed(a)) {
|
|
3368
|
-
let allFound = true;
|
|
3369
|
-
for (const aEntry of a) {
|
|
3370
|
-
if (!b.has(aEntry[0]) || !equals(aEntry[1], b.get(aEntry[0]), [iterableEqualityWithStack])) {
|
|
3371
|
-
let has = false;
|
|
3372
|
-
for (const bEntry of b) {
|
|
3373
|
-
const matchedKey = equals(aEntry[0], bEntry[0], [
|
|
3374
|
-
iterableEqualityWithStack
|
|
3375
|
-
]);
|
|
3376
|
-
let matchedValue = false;
|
|
3377
|
-
if (matchedKey === true) {
|
|
3378
|
-
matchedValue = equals(aEntry[1], bEntry[1], [
|
|
3379
|
-
iterableEqualityWithStack
|
|
3380
|
-
]);
|
|
3381
|
-
}
|
|
3382
|
-
if (matchedValue === true)
|
|
3383
|
-
has = true;
|
|
3384
|
-
}
|
|
3385
|
-
if (has === false) {
|
|
3386
|
-
allFound = false;
|
|
3387
|
-
break;
|
|
3388
|
-
}
|
|
3389
|
-
}
|
|
3390
|
-
}
|
|
3391
|
-
aStack.pop();
|
|
3392
|
-
bStack.pop();
|
|
3393
|
-
return allFound;
|
|
3394
|
-
}
|
|
3395
|
-
}
|
|
3396
|
-
const bIterator = b[IteratorSymbol]();
|
|
3397
|
-
for (const aValue of a) {
|
|
3398
|
-
const nextB = bIterator.next();
|
|
3399
|
-
if (nextB.done || !equals(aValue, nextB.value, [iterableEqualityWithStack]))
|
|
3400
|
-
return false;
|
|
3401
|
-
}
|
|
3402
|
-
if (!bIterator.next().done)
|
|
3403
|
-
return false;
|
|
3404
|
-
aStack.pop();
|
|
3405
|
-
bStack.pop();
|
|
3406
|
-
return true;
|
|
3407
|
-
};
|
|
3408
|
-
const hasPropertyInObject = (object, key) => {
|
|
3409
|
-
const shouldTerminate = !object || typeof object !== "object" || object === Object.prototype;
|
|
3410
|
-
if (shouldTerminate)
|
|
3411
|
-
return false;
|
|
3412
|
-
return Object.prototype.hasOwnProperty.call(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key);
|
|
3413
|
-
};
|
|
3414
|
-
const isObjectWithKeys = (a) => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
|
|
3415
|
-
const subsetEquality = (object, subset) => {
|
|
3416
|
-
const subsetEqualityWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => (object2, subset2) => {
|
|
3417
|
-
if (!isObjectWithKeys(subset2))
|
|
3418
|
-
return void 0;
|
|
3419
|
-
return Object.keys(subset2).every((key) => {
|
|
3420
|
-
if (isObjectWithKeys(subset2[key])) {
|
|
3421
|
-
if (seenReferences.has(subset2[key]))
|
|
3422
|
-
return equals(object2[key], subset2[key], [iterableEquality]);
|
|
3423
|
-
seenReferences.set(subset2[key], true);
|
|
3424
|
-
}
|
|
3425
|
-
const result = object2 != null && hasPropertyInObject(object2, key) && equals(object2[key], subset2[key], [
|
|
3426
|
-
iterableEquality,
|
|
3427
|
-
subsetEqualityWithContext(seenReferences)
|
|
3428
|
-
]);
|
|
3429
|
-
seenReferences.delete(subset2[key]);
|
|
3430
|
-
return result;
|
|
3431
|
-
});
|
|
3432
|
-
};
|
|
3433
|
-
return subsetEqualityWithContext()(object, subset);
|
|
3434
|
-
};
|
|
3435
|
-
|
|
3436
3203
|
var __defProp = Object.defineProperty;
|
|
3437
3204
|
var __defProps = Object.defineProperties;
|
|
3438
3205
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -3500,213 +3267,11 @@ const JestExtend = (chai2, utils) => {
|
|
|
3500
3267
|
});
|
|
3501
3268
|
};
|
|
3502
3269
|
|
|
3503
|
-
const JestChaiExpect = (chai, utils) => {
|
|
3504
|
-
function def(name, fn) {
|
|
3505
|
-
const addMethod = (n) => {
|
|
3506
|
-
utils.addMethod(chai.Assertion.prototype, n, fn);
|
|
3507
|
-
};
|
|
3508
|
-
if (Array.isArray(name))
|
|
3509
|
-
name.forEach((n) => addMethod(n));
|
|
3510
|
-
else
|
|
3511
|
-
addMethod(name);
|
|
3512
|
-
}
|
|
3513
|
-
const chaiEqual = chai.Assertion.prototype.equal;
|
|
3514
|
-
def("chaiEqual", function(...args) {
|
|
3515
|
-
return chaiEqual.apply(this, args);
|
|
3516
|
-
});
|
|
3517
|
-
utils.overwriteMethod(chai.Assertion.prototype, "equal", (_super) => {
|
|
3518
|
-
return function(...args) {
|
|
3519
|
-
const expected = args[0];
|
|
3520
|
-
const actual = utils.flag(this, "object");
|
|
3521
|
-
if (hasAsymmetric(expected)) {
|
|
3522
|
-
this.assert(equals(actual, expected, void 0, true), "not match with #{act}", "should not match with #{act}", actual, expected);
|
|
3523
|
-
} else {
|
|
3524
|
-
_super.apply(this, args);
|
|
3525
|
-
}
|
|
3526
|
-
};
|
|
3527
|
-
});
|
|
3528
|
-
utils.overwriteMethod(chai.Assertion.prototype, "eql", (_super) => {
|
|
3529
|
-
return function(...args) {
|
|
3530
|
-
const expected = args[0];
|
|
3531
|
-
const actual = utils.flag(this, "object");
|
|
3532
|
-
if (hasAsymmetric(expected)) {
|
|
3533
|
-
this.assert(equals(actual, expected), "not match with #{exp}", "should not match with #{exp}", actual, expected);
|
|
3534
|
-
} else {
|
|
3535
|
-
_super.apply(this, args);
|
|
3536
|
-
}
|
|
3537
|
-
};
|
|
3538
|
-
});
|
|
3539
|
-
def("toEqual", function(expected) {
|
|
3540
|
-
return this.eql(expected);
|
|
3541
|
-
});
|
|
3542
|
-
def("toStrictEqual", function(expected) {
|
|
3543
|
-
return this.chaiEqual(expected);
|
|
3544
|
-
});
|
|
3545
|
-
def("toBe", function(expected) {
|
|
3546
|
-
return this.equal(expected);
|
|
3547
|
-
});
|
|
3548
|
-
def("toMatchObject", function(expected) {
|
|
3549
|
-
return this.containSubset(expected);
|
|
3550
|
-
});
|
|
3551
|
-
def("toMatch", function(expected) {
|
|
3552
|
-
if (typeof expected === "string")
|
|
3553
|
-
return this.include(expected);
|
|
3554
|
-
else
|
|
3555
|
-
return this.match(expected);
|
|
3556
|
-
});
|
|
3557
|
-
def("toContain", function(item) {
|
|
3558
|
-
return this.contain(item);
|
|
3559
|
-
});
|
|
3560
|
-
def("toContainEqual", function(expected) {
|
|
3561
|
-
const obj = utils.flag(this, "object");
|
|
3562
|
-
const index = Array.from(obj).findIndex((item) => {
|
|
3563
|
-
try {
|
|
3564
|
-
chai.assert.deepEqual(item, expected);
|
|
3565
|
-
} catch {
|
|
3566
|
-
return false;
|
|
3567
|
-
}
|
|
3568
|
-
return true;
|
|
3569
|
-
});
|
|
3570
|
-
this.assert(index !== -1, "expected #{this} to deep equally contain #{exp}", "expected #{this} to not deep equally contain #{exp}", expected);
|
|
3571
|
-
});
|
|
3572
|
-
def("toBeTruthy", function() {
|
|
3573
|
-
const obj = utils.flag(this, "object");
|
|
3574
|
-
this.assert(Boolean(obj), "expected #{this} to be truthy", "expected #{this} to not be truthy", obj);
|
|
3575
|
-
});
|
|
3576
|
-
def("toBeFalsy", function() {
|
|
3577
|
-
const obj = utils.flag(this, "object");
|
|
3578
|
-
this.assert(!obj, "expected #{this} to be falsy", "expected #{this} to not be falsy", obj);
|
|
3579
|
-
});
|
|
3580
|
-
def("toBeGreaterThan", function(expected) {
|
|
3581
|
-
return this.to.greaterThan(expected);
|
|
3582
|
-
});
|
|
3583
|
-
def("toBeGreaterThanOrEqual", function(expected) {
|
|
3584
|
-
return this.to.greaterThanOrEqual(expected);
|
|
3585
|
-
});
|
|
3586
|
-
def("toBeLessThan", function(expected) {
|
|
3587
|
-
return this.to.lessThan(expected);
|
|
3588
|
-
});
|
|
3589
|
-
def("toBeLessThanOrEqual", function(expected) {
|
|
3590
|
-
return this.to.lessThanOrEqual(expected);
|
|
3591
|
-
});
|
|
3592
|
-
def("toBeNaN", function() {
|
|
3593
|
-
return this.be.NaN;
|
|
3594
|
-
});
|
|
3595
|
-
def("toBeUndefined", function() {
|
|
3596
|
-
return this.be.undefined;
|
|
3597
|
-
});
|
|
3598
|
-
def("toBeNull", function() {
|
|
3599
|
-
return this.be.null;
|
|
3600
|
-
});
|
|
3601
|
-
def("toBeDefined", function() {
|
|
3602
|
-
return this.not.be.undefined;
|
|
3603
|
-
});
|
|
3604
|
-
def("toBeInstanceOf", function(obj) {
|
|
3605
|
-
return this.instanceOf(obj);
|
|
3606
|
-
});
|
|
3607
|
-
def("toHaveLength", function(length) {
|
|
3608
|
-
return this.have.length(length);
|
|
3609
|
-
});
|
|
3610
|
-
def("toHaveProperty", function(...args) {
|
|
3611
|
-
return this.have.deep.nested.property(...args);
|
|
3612
|
-
});
|
|
3613
|
-
def("toBeCloseTo", function(number, numDigits = 2) {
|
|
3614
|
-
utils.expectTypes(this, ["number"]);
|
|
3615
|
-
return this.closeTo(number, numDigits);
|
|
3616
|
-
});
|
|
3617
|
-
function isSpy(putativeSpy) {
|
|
3618
|
-
return typeof putativeSpy === "function" && "__isSpy" in putativeSpy && putativeSpy.__isSpy;
|
|
3619
|
-
}
|
|
3620
|
-
const assertIsMock = (assertion) => {
|
|
3621
|
-
if (!isSpy(assertion._obj))
|
|
3622
|
-
throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`);
|
|
3623
|
-
};
|
|
3624
|
-
const getSpy = (assertion) => {
|
|
3625
|
-
assertIsMock(assertion);
|
|
3626
|
-
return assertion._obj;
|
|
3627
|
-
};
|
|
3628
|
-
def(["toHaveBeenCalledTimes", "toBeCalledTimes"], function(number) {
|
|
3629
|
-
const spy = getSpy(this);
|
|
3630
|
-
return this.assert(spy.callCount === number, "expected spy to be called #{exp} times", "expected spy to not be called #{exp} times", number, spy.callCount);
|
|
3631
|
-
});
|
|
3632
|
-
def("toHaveBeenCalledOnce", function() {
|
|
3633
|
-
const spy = getSpy(this);
|
|
3634
|
-
return this.assert(spy.callCount === 1, "expected spy to be called once", "expected spy to not be called once", 1, spy.callCount);
|
|
3635
|
-
});
|
|
3636
|
-
def(["toHaveBeenCalled", "toBeCalled"], function() {
|
|
3637
|
-
const spy = getSpy(this);
|
|
3638
|
-
return this.assert(spy.called, "expected spy to be called at least once", "expected spy to not be called at all", true, spy.called);
|
|
3639
|
-
});
|
|
3640
|
-
def(["toHaveBeenCalledWith", "toBeCalledWith"], function(...args) {
|
|
3641
|
-
const spy = getSpy(this);
|
|
3642
|
-
const pass = spy.calls.some((callArg) => equals(callArg, args));
|
|
3643
|
-
return this.assert(pass, "expected spy to be called with arguments: #{exp}", "expected spy to not be called with arguments: #{exp}", args, spy.calls);
|
|
3644
|
-
});
|
|
3645
|
-
const ordinalOf = (i) => {
|
|
3646
|
-
const j = i % 10;
|
|
3647
|
-
const k = i % 100;
|
|
3648
|
-
if (j === 1 && k !== 11)
|
|
3649
|
-
return `${i}st`;
|
|
3650
|
-
if (j === 2 && k !== 12)
|
|
3651
|
-
return `${i}nd`;
|
|
3652
|
-
if (j === 3 && k !== 13)
|
|
3653
|
-
return `${i}rd`;
|
|
3654
|
-
return `${i}th`;
|
|
3655
|
-
};
|
|
3656
|
-
def(["toHaveBeenNthCalledWith", "nthCalledWith"], function(times, ...args) {
|
|
3657
|
-
const spy = getSpy(this);
|
|
3658
|
-
const nthCall = spy.calls[times - 1];
|
|
3659
|
-
this.assert(equals(nthCall, args), `expected ${ordinalOf(times)} spy call to have been called with #{exp}`, `expected ${ordinalOf(times)} spy call to not have been called with #{exp}`, args, nthCall);
|
|
3660
|
-
});
|
|
3661
|
-
def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
|
|
3662
|
-
const spy = getSpy(this);
|
|
3663
|
-
const lastCall = spy.calls[spy.calls.length - 1];
|
|
3664
|
-
this.assert(equals(lastCall, args), "expected last spy call to have been called with #{exp}", "expected last spy call to not have been called with #{exp}", args, lastCall);
|
|
3665
|
-
});
|
|
3666
|
-
def(["toThrow", "toThrowError"], function(expected) {
|
|
3667
|
-
const negate = utils.flag(this, "negate");
|
|
3668
|
-
if (negate)
|
|
3669
|
-
this.not.to.throw(expected);
|
|
3670
|
-
else
|
|
3671
|
-
this.to.throw(expected);
|
|
3672
|
-
});
|
|
3673
|
-
def(["toHaveReturned", "toReturn"], function() {
|
|
3674
|
-
const spy = getSpy(this);
|
|
3675
|
-
const calledAndNotThrew = spy.called && !spy.results.some(([type]) => type === "error");
|
|
3676
|
-
this.assert(calledAndNotThrew, "expected spy to be successfully called at least once", "expected spy to not be successfully called", calledAndNotThrew, !calledAndNotThrew);
|
|
3677
|
-
});
|
|
3678
|
-
def(["toHaveReturnedTimes", "toReturnTimes"], function(times) {
|
|
3679
|
-
const spy = getSpy(this);
|
|
3680
|
-
const successfullReturns = spy.results.reduce((success, [type]) => type === "error" ? success : ++success, 0);
|
|
3681
|
-
this.assert(successfullReturns === times, `expected spy to be successfully called ${times} times`, `expected spy to not be successfully called ${times} times`, `expected number of returns: ${times}`, `received number of returns: ${successfullReturns}`);
|
|
3682
|
-
});
|
|
3683
|
-
def(["toHaveReturnedWith", "toReturnWith"], function(value) {
|
|
3684
|
-
const spy = getSpy(this);
|
|
3685
|
-
const pass = spy.results.some(([type, result]) => type === "ok" && equals(value, result));
|
|
3686
|
-
this.assert(pass, "expected spy to be successfully called with #{exp}", "expected spy to not be successfully called with #{exp}", value);
|
|
3687
|
-
});
|
|
3688
|
-
def(["toHaveLastReturnedWith", "lastReturnedWith"], function(value) {
|
|
3689
|
-
const spy = getSpy(this);
|
|
3690
|
-
const lastResult = spy.returns[spy.returns.length - 1];
|
|
3691
|
-
const pass = equals(lastResult, value);
|
|
3692
|
-
this.assert(pass, "expected last spy call to return #{exp}", "expected last spy call to not return #{exp}", value, lastResult);
|
|
3693
|
-
});
|
|
3694
|
-
def(["toHaveNthReturnedWith", "nthReturnedWith"], function(nthCall, value) {
|
|
3695
|
-
const spy = getSpy(this);
|
|
3696
|
-
const isNot = utils.flag(this, "negate");
|
|
3697
|
-
const [callType, callResult] = spy.results[nthCall - 1];
|
|
3698
|
-
const ordinalCall = `${ordinalOf(nthCall)} call`;
|
|
3699
|
-
if (!isNot && callType === "error")
|
|
3700
|
-
chai.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);
|
|
3701
|
-
const nthCallReturn = equals(callResult, value);
|
|
3702
|
-
this.assert(nthCallReturn, `expected ${ordinalCall} spy call to return #{exp}`, `expected ${ordinalCall} spy call to not return #{exp}`, value, callResult);
|
|
3703
|
-
});
|
|
3704
|
-
};
|
|
3705
|
-
|
|
3706
3270
|
class AsymmetricMatcher {
|
|
3707
3271
|
constructor(sample, inverse = false) {
|
|
3708
3272
|
this.sample = sample;
|
|
3709
3273
|
this.inverse = inverse;
|
|
3274
|
+
this.$$typeof = Symbol.for("jest.asymmetricMatcher");
|
|
3710
3275
|
}
|
|
3711
3276
|
getMatcherContext() {
|
|
3712
3277
|
return {
|
|
@@ -3907,7 +3472,7 @@ async function setupGlobalEnv(config) {
|
|
|
3907
3472
|
setupConsoleLogSpy();
|
|
3908
3473
|
await setupChai();
|
|
3909
3474
|
if (config.global)
|
|
3910
|
-
(await import('./global-
|
|
3475
|
+
(await import('./global-201fd559.js')).registerApiGlobally();
|
|
3911
3476
|
}
|
|
3912
3477
|
function setupConsoleLogSpy() {
|
|
3913
3478
|
const stdout = new Writable({
|
|
@@ -3932,13 +3497,12 @@ function setupConsoleLogSpy() {
|
|
|
3932
3497
|
callback();
|
|
3933
3498
|
}
|
|
3934
3499
|
});
|
|
3935
|
-
|
|
3500
|
+
globalThis.console = new Console({
|
|
3936
3501
|
stdout,
|
|
3937
3502
|
stderr,
|
|
3938
3503
|
colorMode: true,
|
|
3939
3504
|
groupIndentation: 2
|
|
3940
3505
|
});
|
|
3941
|
-
globalThis.console = newConsole;
|
|
3942
3506
|
}
|
|
3943
3507
|
async function withEnv(name, fn) {
|
|
3944
3508
|
const env = await environments[name].setup(globalThis);
|
|
@@ -3957,7 +3521,7 @@ async function runSetupFiles(config) {
|
|
|
3957
3521
|
}
|
|
3958
3522
|
|
|
3959
3523
|
function serializeError(val) {
|
|
3960
|
-
if (!val)
|
|
3524
|
+
if (!val || typeof val === "string")
|
|
3961
3525
|
return val;
|
|
3962
3526
|
if (typeof val === "function")
|
|
3963
3527
|
return `Function<${val.name}>`;
|
|
@@ -3981,6 +3545,10 @@ function processError(err) {
|
|
|
3981
3545
|
err.stackStr = String(err.stack);
|
|
3982
3546
|
if (err.name)
|
|
3983
3547
|
err.nameStr = String(err.name);
|
|
3548
|
+
if (typeof err.expected !== "string")
|
|
3549
|
+
err.expected = stringify(err.expected);
|
|
3550
|
+
if (typeof err.actual !== "string")
|
|
3551
|
+
err.actual = stringify(err.actual);
|
|
3984
3552
|
return serializeError(err);
|
|
3985
3553
|
}
|
|
3986
3554
|
|
|
@@ -3989,7 +3557,7 @@ async function collectTests(paths, config) {
|
|
|
3989
3557
|
for (const filepath of paths) {
|
|
3990
3558
|
const file = {
|
|
3991
3559
|
id: nanoid(),
|
|
3992
|
-
name:
|
|
3560
|
+
name: relative(config.root, filepath),
|
|
3993
3561
|
type: "suite",
|
|
3994
3562
|
mode: "run",
|
|
3995
3563
|
computeMode: "serial",
|
|
@@ -4051,7 +3619,11 @@ async function runTest(test) {
|
|
|
4051
3619
|
process.__vitest_worker__.current = test;
|
|
4052
3620
|
try {
|
|
4053
3621
|
await callSuiteHook(test.suite, "beforeEach", [test, test.suite]);
|
|
3622
|
+
setState({ assertionCalls: 0, expectedAssertionsNumber: null, expectedAssertionsNumberError: null });
|
|
4054
3623
|
await getFn(test)();
|
|
3624
|
+
const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberError } = getState();
|
|
3625
|
+
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
3626
|
+
throw expectedAssertionsNumberError;
|
|
4055
3627
|
test.result.state = "pass";
|
|
4056
3628
|
} catch (e) {
|
|
4057
3629
|
test.result.state = "fail";
|
|
@@ -4135,6 +3707,15 @@ async function startTests(paths, config) {
|
|
|
4135
3707
|
await runSuites(files);
|
|
4136
3708
|
await getSnapshotClient().saveSnap();
|
|
4137
3709
|
}
|
|
3710
|
+
function clearModuleMocks() {
|
|
3711
|
+
const { clearMocks, mockReset, restoreMocks } = process.__vitest_worker__.config;
|
|
3712
|
+
if (restoreMocks)
|
|
3713
|
+
vi.restoreAllMocks();
|
|
3714
|
+
else if (mockReset)
|
|
3715
|
+
vi.resetAllMocks();
|
|
3716
|
+
else if (clearMocks)
|
|
3717
|
+
vi.clearAllMocks();
|
|
3718
|
+
}
|
|
4138
3719
|
|
|
4139
3720
|
async function run(files, config) {
|
|
4140
3721
|
var _a;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { g as globalApis } from './constants-2b0310b7.js';
|
|
2
|
+
import { i as index } from './index-2bb9fd4d.js';
|
|
3
|
+
import 'url';
|
|
4
|
+
import './utils-cb6b1266.js';
|
|
5
|
+
import 'tty';
|
|
6
|
+
import 'local-pkg';
|
|
7
|
+
import 'path';
|
|
8
|
+
import './vi-cb9e4e4e.js';
|
|
9
|
+
import './jest-mock-a57b745c.js';
|
|
10
|
+
import 'chai';
|
|
11
|
+
import 'tinyspy';
|
|
12
|
+
import './_commonjsHelpers-c9e3b764.js';
|
|
13
|
+
|
|
14
|
+
function registerApiGlobally() {
|
|
15
|
+
globalApis.forEach((api) => {
|
|
16
|
+
globalThis[api] = index[api];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { registerApiGlobally };
|