MCPcopy Create free account
hub / github.com/denoland/std / assertSpyCalls

Function assertSpyCalls

testing/mock.ts:1174–1192  ·  view source on GitHub ↗
(
  spy: SpyLike<Self, Args, Return>,
  expectedCalls: number,
)

Source from the content-addressed store, hash-verified

1172 * @param expectedCalls The number of the expected calls.
1173 */
1174export function assertSpyCalls<
1175 Self,
1176 Args extends unknown[],
1177 Return,
1178>(
1179 spy: SpyLike<Self, Args, Return>,
1180 expectedCalls: number,
1181) {
1182 try {
1183 assertEquals(spy.calls.length, expectedCalls);
1184 } catch (e) {
1185 assertIsError(e);
1186 let message = spy.calls.length < expectedCalls
1187 ? "Spy not called as much as expected:\n"
1188 : "Spy called more than expected:\n";
1189 message += e.message.split("\n").slice(1).join("\n");
1190 throw new AssertionError(message);
1191 }
1192}
1193
1194/** Call information recorded by a spy. */
1195export interface ExpectedSpyCall<

Callers 12

delay_test.tsFile · 0.90
fnFunction · 0.90
bdd_test.tsFile · 0.90
assertOptionsFunction · 0.90
assertIgnoreOptionsFunction · 0.90
assertOnlyFunction · 0.90
assertHooksFunction · 0.90
assertDescribeOptionsFunction · 0.90
assertItOptionsFunction · 0.90
mock_test.tsFile · 0.90

Calls 3

assertEqualsFunction · 0.90
assertIsErrorFunction · 0.50
sliceMethod · 0.45

Tested by

no test coverage detected