MCPcopy
hub / github.com/jestjs/jest / asymmetricMatch

Method asymmetricMatch

packages/expect/src/asymmetricMatchers.ts:198–217  ·  view source on GitHub ↗
(other: unknown)

Source from the content-addressed store, hash-verified

196 }
197
198 asymmetricMatch(other: unknown) {
199 if (!Array.isArray(this.sample)) {
200 throw new TypeError(
201 `You must provide an array to ${this.toString()}, not '${typeof this
202 .sample}'.`,
203 );
204 }
205
206 const matcherContext = this.getMatcherContext();
207 const result =
208 this.sample.length === 0 ||
209 (Array.isArray(other) &&
210 this.sample.every(item =>
211 other.some(another =>
212 equals(item, another, matcherContext.customTesters),
213 ),
214 ));
215
216 return this.inverse ? !result : result;
217 }
218
219 toString() {
220 return `Array${this.inverse ? 'Not' : ''}Containing`;

Callers

nothing calls this directly

Calls 2

toStringMethod · 0.95
equalsFunction · 0.90

Tested by

no test coverage detected