@vitest/expect 1.1.3 → 1.2.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/index.d.ts +16 -30
- package/dist/index.js +66 -35
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import * as _vitest_utils from '@vitest/utils';
|
1
2
|
import { stringify, Constructable } from '@vitest/utils';
|
2
3
|
export { setupColors } from '@vitest/utils';
|
3
4
|
import { diff } from '@vitest/utils/diff';
|
@@ -6,35 +7,16 @@ export { DiffOptions } from '@vitest/utils/diff';
|
|
6
7
|
type Formatter = (input: string | number | null | undefined) => string;
|
7
8
|
|
8
9
|
declare function getMatcherUtils(): {
|
9
|
-
EXPECTED_COLOR:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
RECEIVED_COLOR: {
|
15
|
-
(input: unknown): string;
|
16
|
-
open: string;
|
17
|
-
close: string;
|
18
|
-
};
|
19
|
-
INVERTED_COLOR: {
|
20
|
-
(input: unknown): string;
|
21
|
-
open: string;
|
22
|
-
close: string;
|
23
|
-
};
|
24
|
-
BOLD_WEIGHT: {
|
25
|
-
(input: unknown): string;
|
26
|
-
open: string;
|
27
|
-
close: string;
|
28
|
-
};
|
29
|
-
DIM_COLOR: {
|
30
|
-
(input: unknown): string;
|
31
|
-
open: string;
|
32
|
-
close: string;
|
33
|
-
};
|
10
|
+
EXPECTED_COLOR: _vitest_utils.ColorMethod;
|
11
|
+
RECEIVED_COLOR: _vitest_utils.ColorMethod;
|
12
|
+
INVERTED_COLOR: _vitest_utils.ColorMethod;
|
13
|
+
BOLD_WEIGHT: _vitest_utils.ColorMethod;
|
14
|
+
DIM_COLOR: _vitest_utils.ColorMethod;
|
34
15
|
matcherHint: (matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions) => string;
|
35
16
|
printReceived: (object: unknown) => string;
|
36
17
|
printExpected: (value: unknown) => string;
|
37
18
|
};
|
19
|
+
declare function addCustomEqualityTesters(newTesters: Array<Tester>): void;
|
38
20
|
|
39
21
|
/**
|
40
22
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
@@ -45,7 +27,10 @@ declare function getMatcherUtils(): {
|
|
45
27
|
*/
|
46
28
|
|
47
29
|
type ChaiPlugin = Chai.ChaiPlugin;
|
48
|
-
type Tester = (a: any, b: any) => boolean | undefined;
|
30
|
+
type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
|
31
|
+
interface TesterContext {
|
32
|
+
equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
|
33
|
+
}
|
49
34
|
|
50
35
|
interface MatcherHintOptions {
|
51
36
|
comment?: string;
|
@@ -98,6 +83,7 @@ interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
|
|
98
83
|
unreachable(message?: string): never;
|
99
84
|
soft<T>(actual: T, message?: string): Assertion<T>;
|
100
85
|
extend(expects: MatchersObject): void;
|
86
|
+
addEqualityTesters(testers: Array<Tester>): void;
|
101
87
|
assertions(expected: number): void;
|
102
88
|
hasAssertions(): void;
|
103
89
|
anything(): any;
|
@@ -244,11 +230,11 @@ declare function fnNameFor(func: Function): string;
|
|
244
230
|
declare function hasProperty(obj: object | null, property: string): boolean;
|
245
231
|
declare function isImmutableUnorderedKeyed(maybeKeyed: any): boolean;
|
246
232
|
declare function isImmutableUnorderedSet(maybeSet: any): boolean;
|
247
|
-
declare function iterableEquality(a: any, b: any, aStack?: Array<any>, bStack?: Array<any>): boolean | undefined;
|
248
|
-
declare function subsetEquality(object: unknown, subset: unknown): boolean | undefined;
|
233
|
+
declare function iterableEquality(a: any, b: any, customTesters?: Array<Tester>, aStack?: Array<any>, bStack?: Array<any>): boolean | undefined;
|
234
|
+
declare function subsetEquality(object: unknown, subset: unknown, customTesters?: Array<Tester>): boolean | undefined;
|
249
235
|
declare function typeEquality(a: any, b: any): boolean | undefined;
|
250
236
|
declare function arrayBufferEquality(a: unknown, b: unknown): boolean | undefined;
|
251
|
-
declare function sparseArrayEquality(a: unknown, b: unknown): boolean | undefined;
|
237
|
+
declare function sparseArrayEquality(a: unknown, b: unknown, customTesters?: Array<Tester>): boolean | undefined;
|
252
238
|
declare function generateToBeMessage(deepEqualityName: string, expected?: string, actual?: string): string;
|
253
239
|
declare function pluralize(word: string, count: number): string;
|
254
240
|
|
@@ -264,4 +250,4 @@ declare const JestChaiExpect: ChaiPlugin;
|
|
264
250
|
|
265
251
|
declare const JestExtend: ChaiPlugin;
|
266
252
|
|
267
|
-
export { ASYMMETRIC_MATCHERS_OBJECT, Any, Anything, ArrayContaining, type Assertion, AsymmetricMatcher, type AsymmetricMatcherInterface, type AsymmetricMatchersContaining, type AsyncExpectationResult, type ChaiPlugin, type ExpectStatic, type ExpectationResult, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, type JestAssertion, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, type MatcherHintOptions, type MatcherState, type MatchersObject, ObjectContaining, type RawMatcherFn, StringContaining, StringMatching, type SyncExpectationResult, type Tester, arrayBufferEquality, equals, fnNameFor, generateToBeMessage, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, iterableEquality, pluralize, setState, sparseArrayEquality, subsetEquality, typeEquality };
|
253
|
+
export { ASYMMETRIC_MATCHERS_OBJECT, Any, Anything, ArrayContaining, type Assertion, AsymmetricMatcher, type AsymmetricMatcherInterface, type AsymmetricMatchersContaining, type AsyncExpectationResult, type ChaiPlugin, type ExpectStatic, type ExpectationResult, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, type JestAssertion, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, type MatcherHintOptions, type MatcherState, type MatchersObject, ObjectContaining, type RawMatcherFn, StringContaining, StringMatching, type SyncExpectationResult, type Tester, type TesterContext, addCustomEqualityTesters, arrayBufferEquality, equals, fnNameFor, generateToBeMessage, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, iterableEquality, pluralize, setState, sparseArrayEquality, subsetEquality, typeEquality };
|
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getColors, stringify, isObject, assertTypes } from '@vitest/utils';
|
1
|
+
import { getType, getColors, stringify, isObject, assertTypes } from '@vitest/utils';
|
2
2
|
export { setupColors } from '@vitest/utils';
|
3
3
|
import { diff } from '@vitest/utils/diff';
|
4
4
|
import { isMockFunction } from '@vitest/spy';
|
@@ -13,6 +13,7 @@ const ASYMMETRIC_MATCHERS_OBJECT = Symbol.for("asymmetric-matchers-object");
|
|
13
13
|
if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
14
14
|
const globalState = /* @__PURE__ */ new WeakMap();
|
15
15
|
const matchers = /* @__PURE__ */ Object.create(null);
|
16
|
+
const customEqualityTesters = [];
|
16
17
|
const assymetricMatchers = /* @__PURE__ */ Object.create(null);
|
17
18
|
Object.defineProperty(globalThis, MATCHERS_OBJECT, {
|
18
19
|
get: () => globalState
|
@@ -21,7 +22,8 @@ if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
|
21
22
|
configurable: true,
|
22
23
|
get: () => ({
|
23
24
|
state: globalState.get(globalThis[GLOBAL_EXPECT]),
|
24
|
-
matchers
|
25
|
+
matchers,
|
26
|
+
customEqualityTesters
|
25
27
|
})
|
26
28
|
});
|
27
29
|
Object.defineProperty(globalThis, ASYMMETRIC_MATCHERS_OBJECT, {
|
@@ -106,6 +108,21 @@ function getMatcherUtils() {
|
|
106
108
|
printExpected
|
107
109
|
};
|
108
110
|
}
|
111
|
+
function addCustomEqualityTesters(newTesters) {
|
112
|
+
if (!Array.isArray(newTesters)) {
|
113
|
+
throw new TypeError(
|
114
|
+
`expect.customEqualityTesters: Must be set to an array of Testers. Was given "${getType(
|
115
|
+
newTesters
|
116
|
+
)}"`
|
117
|
+
);
|
118
|
+
}
|
119
|
+
globalThis[JEST_MATCHERS_OBJECT].customEqualityTesters.push(
|
120
|
+
...newTesters
|
121
|
+
);
|
122
|
+
}
|
123
|
+
function getCustomEqualityTesters() {
|
124
|
+
return globalThis[JEST_MATCHERS_OBJECT].customEqualityTesters;
|
125
|
+
}
|
109
126
|
|
110
127
|
function equals(a, b, customTesters, strictCheck) {
|
111
128
|
customTesters = customTesters || [];
|
@@ -144,8 +161,9 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
144
161
|
const asymmetricResult = asymmetricMatch(a, b);
|
145
162
|
if (asymmetricResult !== void 0)
|
146
163
|
return asymmetricResult;
|
164
|
+
const testerContext = { equals };
|
147
165
|
for (let i = 0; i < customTesters.length; i++) {
|
148
|
-
const customTesterResult = customTesters[i](a, b);
|
166
|
+
const customTesterResult = customTesters[i].call(testerContext, a, b, customTesters);
|
149
167
|
if (customTesterResult !== void 0)
|
150
168
|
return customTesterResult;
|
151
169
|
}
|
@@ -266,7 +284,7 @@ const IteratorSymbol = Symbol.iterator;
|
|
266
284
|
function hasIterator(object) {
|
267
285
|
return !!(object != null && object[IteratorSymbol]);
|
268
286
|
}
|
269
|
-
function iterableEquality(a, b, aStack = [], bStack = []) {
|
287
|
+
function iterableEquality(a, b, customTesters = [], aStack = [], bStack = []) {
|
270
288
|
if (typeof a !== "object" || typeof b !== "object" || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b))
|
271
289
|
return void 0;
|
272
290
|
if (a.constructor !== b.constructor)
|
@@ -278,7 +296,19 @@ function iterableEquality(a, b, aStack = [], bStack = []) {
|
|
278
296
|
}
|
279
297
|
aStack.push(a);
|
280
298
|
bStack.push(b);
|
281
|
-
const
|
299
|
+
const filteredCustomTesters = [
|
300
|
+
...customTesters.filter((t) => t !== iterableEquality),
|
301
|
+
iterableEqualityWithStack
|
302
|
+
];
|
303
|
+
function iterableEqualityWithStack(a2, b2) {
|
304
|
+
return iterableEquality(
|
305
|
+
a2,
|
306
|
+
b2,
|
307
|
+
[...filteredCustomTesters],
|
308
|
+
[...aStack],
|
309
|
+
[...bStack]
|
310
|
+
);
|
311
|
+
}
|
282
312
|
if (a.size !== void 0) {
|
283
313
|
if (a.size !== b.size) {
|
284
314
|
return false;
|
@@ -288,7 +318,7 @@ function iterableEquality(a, b, aStack = [], bStack = []) {
|
|
288
318
|
if (!b.has(aValue)) {
|
289
319
|
let has = false;
|
290
320
|
for (const bValue of b) {
|
291
|
-
const isEqual = equals(aValue, bValue,
|
321
|
+
const isEqual = equals(aValue, bValue, filteredCustomTesters);
|
292
322
|
if (isEqual === true)
|
293
323
|
has = true;
|
294
324
|
}
|
@@ -304,18 +334,13 @@ function iterableEquality(a, b, aStack = [], bStack = []) {
|
|
304
334
|
} else if (isA("Map", a) || isImmutableUnorderedKeyed(a)) {
|
305
335
|
let allFound = true;
|
306
336
|
for (const aEntry of a) {
|
307
|
-
if (!b.has(aEntry[0]) || !equals(aEntry[1], b.get(aEntry[0]),
|
337
|
+
if (!b.has(aEntry[0]) || !equals(aEntry[1], b.get(aEntry[0]), filteredCustomTesters)) {
|
308
338
|
let has = false;
|
309
339
|
for (const bEntry of b) {
|
310
|
-
const matchedKey = equals(aEntry[0], bEntry[0],
|
311
|
-
iterableEqualityWithStack
|
312
|
-
]);
|
340
|
+
const matchedKey = equals(aEntry[0], bEntry[0], filteredCustomTesters);
|
313
341
|
let matchedValue = false;
|
314
|
-
if (matchedKey === true)
|
315
|
-
matchedValue = equals(aEntry[1], bEntry[1],
|
316
|
-
iterableEqualityWithStack
|
317
|
-
]);
|
318
|
-
}
|
342
|
+
if (matchedKey === true)
|
343
|
+
matchedValue = equals(aEntry[1], bEntry[1], filteredCustomTesters);
|
319
344
|
if (matchedValue === true)
|
320
345
|
has = true;
|
321
346
|
}
|
@@ -333,7 +358,7 @@ function iterableEquality(a, b, aStack = [], bStack = []) {
|
|
333
358
|
const bIterator = b[IteratorSymbol]();
|
334
359
|
for (const aValue of a) {
|
335
360
|
const nextB = bIterator.next();
|
336
|
-
if (nextB.done || !equals(aValue, nextB.value,
|
361
|
+
if (nextB.done || !equals(aValue, nextB.value, filteredCustomTesters))
|
337
362
|
return false;
|
338
363
|
}
|
339
364
|
if (!bIterator.next().done)
|
@@ -351,18 +376,19 @@ function hasPropertyInObject(object, key) {
|
|
351
376
|
function isObjectWithKeys(a) {
|
352
377
|
return isObject(a) && !(a instanceof Error) && !Array.isArray(a) && !(a instanceof Date);
|
353
378
|
}
|
354
|
-
function subsetEquality(object, subset) {
|
379
|
+
function subsetEquality(object, subset, customTesters = []) {
|
380
|
+
const filteredCustomTesters = customTesters.filter((t) => t !== subsetEquality);
|
355
381
|
const subsetEqualityWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => (object2, subset2) => {
|
356
382
|
if (!isObjectWithKeys(subset2))
|
357
383
|
return void 0;
|
358
384
|
return Object.keys(subset2).every((key) => {
|
359
385
|
if (isObjectWithKeys(subset2[key])) {
|
360
386
|
if (seenReferences.has(subset2[key]))
|
361
|
-
return equals(object2[key], subset2[key],
|
387
|
+
return equals(object2[key], subset2[key], filteredCustomTesters);
|
362
388
|
seenReferences.set(subset2[key], true);
|
363
389
|
}
|
364
390
|
const result = object2 != null && hasPropertyInObject(object2, key) && equals(object2[key], subset2[key], [
|
365
|
-
|
391
|
+
...filteredCustomTesters,
|
366
392
|
subsetEqualityWithContext(seenReferences)
|
367
393
|
]);
|
368
394
|
seenReferences.delete(subset2[key]);
|
@@ -397,12 +423,13 @@ function arrayBufferEquality(a, b) {
|
|
397
423
|
}
|
398
424
|
return true;
|
399
425
|
}
|
400
|
-
function sparseArrayEquality(a, b) {
|
426
|
+
function sparseArrayEquality(a, b, customTesters = []) {
|
401
427
|
if (!Array.isArray(a) || !Array.isArray(b))
|
402
428
|
return void 0;
|
403
429
|
const aKeys = Object.keys(a);
|
404
430
|
const bKeys = Object.keys(b);
|
405
|
-
|
431
|
+
const filteredCustomTesters = customTesters.filter((t) => t !== sparseArrayEquality);
|
432
|
+
return equals(a, b, filteredCustomTesters, true) && equals(aKeys, bKeys);
|
406
433
|
}
|
407
434
|
function generateToBeMessage(deepEqualityName, expected = "#{this}", actual = "#{exp}") {
|
408
435
|
const toBeMessage = `expected ${expected} to be ${actual} // Object.is equality`;
|
@@ -432,7 +459,7 @@ class AsymmetricMatcher {
|
|
432
459
|
...getState(expect || globalThis[GLOBAL_EXPECT]),
|
433
460
|
equals,
|
434
461
|
isNot: this.inverse,
|
435
|
-
customTesters:
|
462
|
+
customTesters: getCustomEqualityTesters(),
|
436
463
|
utils: {
|
437
464
|
...getMatcherUtils(),
|
438
465
|
diff,
|
@@ -496,8 +523,9 @@ class ObjectContaining extends AsymmetricMatcher {
|
|
496
523
|
);
|
497
524
|
}
|
498
525
|
let result = true;
|
526
|
+
const matcherContext = this.getMatcherContext();
|
499
527
|
for (const property in this.sample) {
|
500
|
-
if (!this.hasProperty(other, property) || !equals(this.sample[property], other[property])) {
|
528
|
+
if (!this.hasProperty(other, property) || !equals(this.sample[property], other[property], matcherContext.customTesters)) {
|
501
529
|
result = false;
|
502
530
|
break;
|
503
531
|
}
|
@@ -521,8 +549,9 @@ class ArrayContaining extends AsymmetricMatcher {
|
|
521
549
|
`You must provide an array to ${this.toString()}, not '${typeof this.sample}'.`
|
522
550
|
);
|
523
551
|
}
|
552
|
+
const matcherContext = this.getMatcherContext();
|
524
553
|
const result = this.sample.length === 0 || Array.isArray(other) && this.sample.every(
|
525
|
-
(item) => other.some((another) => equals(item, another))
|
554
|
+
(item) => other.some((another) => equals(item, another, matcherContext.customTesters))
|
526
555
|
);
|
527
556
|
return this.inverse ? !result : result;
|
528
557
|
}
|
@@ -722,6 +751,7 @@ function wrapSoft(utils, fn) {
|
|
722
751
|
const JestChaiExpect = (chai, utils) => {
|
723
752
|
const { AssertionError } = chai;
|
724
753
|
const c = () => getColors();
|
754
|
+
const customTesters = getCustomEqualityTesters();
|
725
755
|
function def(name, fn) {
|
726
756
|
const addMethod = (n) => {
|
727
757
|
const softWrapper = wrapSoft(utils, fn);
|
@@ -767,7 +797,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
767
797
|
const equal = equals(
|
768
798
|
actual,
|
769
799
|
expected,
|
770
|
-
[iterableEquality]
|
800
|
+
[...customTesters, iterableEquality]
|
771
801
|
);
|
772
802
|
return this.assert(
|
773
803
|
equal,
|
@@ -783,6 +813,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
783
813
|
obj,
|
784
814
|
expected,
|
785
815
|
[
|
816
|
+
...customTesters,
|
786
817
|
iterableEquality,
|
787
818
|
typeEquality,
|
788
819
|
sparseArrayEquality,
|
@@ -807,6 +838,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
807
838
|
actual,
|
808
839
|
expected,
|
809
840
|
[
|
841
|
+
...customTesters,
|
810
842
|
iterableEquality,
|
811
843
|
typeEquality,
|
812
844
|
sparseArrayEquality,
|
@@ -820,7 +852,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
820
852
|
const toEqualPass = equals(
|
821
853
|
actual,
|
822
854
|
expected,
|
823
|
-
[iterableEquality]
|
855
|
+
[...customTesters, iterableEquality]
|
824
856
|
);
|
825
857
|
if (toEqualPass)
|
826
858
|
deepEqualityName = "toEqual";
|
@@ -837,7 +869,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
837
869
|
def("toMatchObject", function(expected) {
|
838
870
|
const actual = this._obj;
|
839
871
|
return this.assert(
|
840
|
-
equals(actual, expected, [iterableEquality, subsetEquality]),
|
872
|
+
equals(actual, expected, [...customTesters, iterableEquality, subsetEquality]),
|
841
873
|
"expected #{this} to match object #{exp}",
|
842
874
|
"expected #{this} to not match object #{exp}",
|
843
875
|
expected,
|
@@ -882,7 +914,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
882
914
|
def("toContainEqual", function(expected) {
|
883
915
|
const obj = utils.flag(this, "object");
|
884
916
|
const index = Array.from(obj).findIndex((item) => {
|
885
|
-
return equals(item, expected);
|
917
|
+
return equals(item, expected, customTesters);
|
886
918
|
});
|
887
919
|
this.assert(
|
888
920
|
index !== -1,
|
@@ -1008,7 +1040,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
1008
1040
|
return utils.getPathInfo(actual, propertyName);
|
1009
1041
|
};
|
1010
1042
|
const { value, exists } = getValue();
|
1011
|
-
const pass = exists && (args.length === 1 || equals(expected, value));
|
1043
|
+
const pass = exists && (args.length === 1 || equals(expected, value, customTesters));
|
1012
1044
|
const valueString = args.length === 1 ? "" : ` with value ${utils.objDisplay(expected)}`;
|
1013
1045
|
return this.assert(
|
1014
1046
|
pass,
|
@@ -1156,7 +1188,7 @@ Number of calls: ${c().bold(spy.mock.calls.length)}
|
|
1156
1188
|
def(["toHaveBeenCalledWith", "toBeCalledWith"], function(...args) {
|
1157
1189
|
const spy = getSpy(this);
|
1158
1190
|
const spyName = spy.getMockName();
|
1159
|
-
const pass = spy.mock.calls.some((callArg) => equals(callArg, args, [iterableEquality]));
|
1191
|
+
const pass = spy.mock.calls.some((callArg) => equals(callArg, args, [...customTesters, iterableEquality]));
|
1160
1192
|
const isNot = utils.flag(this, "negate");
|
1161
1193
|
const msg = utils.getMessage(
|
1162
1194
|
this,
|
@@ -1175,7 +1207,7 @@ Number of calls: ${c().bold(spy.mock.calls.length)}
|
|
1175
1207
|
const spyName = spy.getMockName();
|
1176
1208
|
const nthCall = spy.mock.calls[times - 1];
|
1177
1209
|
this.assert(
|
1178
|
-
equals(nthCall, args, [iterableEquality]),
|
1210
|
+
equals(nthCall, args, [...customTesters, iterableEquality]),
|
1179
1211
|
`expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`,
|
1180
1212
|
`expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`,
|
1181
1213
|
args,
|
@@ -1187,7 +1219,7 @@ Number of calls: ${c().bold(spy.mock.calls.length)}
|
|
1187
1219
|
const spyName = spy.getMockName();
|
1188
1220
|
const lastCall = spy.mock.calls[spy.mock.calls.length - 1];
|
1189
1221
|
this.assert(
|
1190
|
-
equals(lastCall, args, [iterableEquality]),
|
1222
|
+
equals(lastCall, args, [...customTesters, iterableEquality]),
|
1191
1223
|
`expected last "${spyName}" call to have been called with #{exp}`,
|
1192
1224
|
`expected last "${spyName}" call to not have been called with #{exp}`,
|
1193
1225
|
args,
|
@@ -1423,8 +1455,7 @@ function getMatcherState(assertion, expect) {
|
|
1423
1455
|
};
|
1424
1456
|
const matcherState = {
|
1425
1457
|
...getState(expect),
|
1426
|
-
|
1427
|
-
customTesters: [],
|
1458
|
+
customTesters: getCustomEqualityTesters(),
|
1428
1459
|
isNot,
|
1429
1460
|
utils: jestUtils,
|
1430
1461
|
promise,
|
@@ -1514,4 +1545,4 @@ const JestExtend = (chai, utils) => {
|
|
1514
1545
|
});
|
1515
1546
|
};
|
1516
1547
|
|
1517
|
-
export { ASYMMETRIC_MATCHERS_OBJECT, Any, Anything, ArrayContaining, AsymmetricMatcher, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, ObjectContaining, StringContaining, StringMatching, arrayBufferEquality, equals, fnNameFor, generateToBeMessage, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, iterableEquality, pluralize, setState, sparseArrayEquality, subsetEquality, typeEquality };
|
1548
|
+
export { ASYMMETRIC_MATCHERS_OBJECT, Any, Anything, ArrayContaining, AsymmetricMatcher, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, ObjectContaining, StringContaining, StringMatching, addCustomEqualityTesters, arrayBufferEquality, equals, fnNameFor, generateToBeMessage, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, iterableEquality, pluralize, setState, sparseArrayEquality, subsetEquality, typeEquality };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/expect",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.2.0",
|
5
5
|
"description": "Jest's expect matchers as a Chai plugin",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -31,14 +31,14 @@
|
|
31
31
|
],
|
32
32
|
"dependencies": {
|
33
33
|
"chai": "^4.3.10",
|
34
|
-
"@vitest/spy": "1.
|
35
|
-
"@vitest/utils": "1.
|
34
|
+
"@vitest/spy": "1.2.0",
|
35
|
+
"@vitest/utils": "1.2.0"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
38
|
"@types/chai": "4.3.6",
|
39
39
|
"picocolors": "^1.0.0",
|
40
40
|
"rollup-plugin-copy": "^3.5.0",
|
41
|
-
"@vitest/runner": "1.
|
41
|
+
"@vitest/runner": "1.2.0"
|
42
42
|
},
|
43
43
|
"scripts": {
|
44
44
|
"build": "rimraf dist && rollup -c",
|