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

Function ensureMockOrSpy

packages/expect/src/spyMatchers.ts:1265–1280  ·  view source on GitHub ↗
(
  received: any,
  matcherName: string,
  expectedArgument: string,
  options: MatcherHintOptions,
)

Source from the content-addressed store, hash-verified

1263 typeof received.calls.count === 'function';
1264
1265const ensureMockOrSpy = (
1266 received: any,
1267 matcherName: string,
1268 expectedArgument: string,
1269 options: MatcherHintOptions,
1270) => {
1271 if (!isMock(received) && !isSpy(received)) {
1272 throw new Error(
1273 matcherErrorMessage(
1274 matcherHint(matcherName, undefined, expectedArgument, options),
1275 `${RECEIVED_COLOR('received')} value must be a mock or spy function`,
1276 printWithType('Received', received, printReceived),
1277 ),
1278 );
1279 }
1280};
1281
1282const ensureMock = (
1283 received: any,

Calls 5

matcherErrorMessageFunction · 0.90
matcherHintFunction · 0.90
printWithTypeFunction · 0.90
isMockFunction · 0.85
isSpyFunction · 0.70

Tested by

no test coverage detected