MCPcopy
hub / github.com/vitest-dev/vitest / formatCalls

Function formatCalls

packages/expect/src/jest-expect.ts:1218–1248  ·  view source on GitHub ↗
(spy: MockInstance, msg: string, showActualCall?: any)

Source from the content-addressed store, hash-verified

1216}
1217
1218function formatCalls(spy: MockInstance, msg: string, showActualCall?: any) {
1219 if (spy.mock.calls.length) {
1220 msg += c.gray(
1221 `\n\nReceived:\n\n${spy.mock.calls
1222 .map((callArg, i) => {
1223 let methodCall = c.bold(
1224 ` ${ordinal(i + 1)} ${spy.getMockName()} call:\n\n`,
1225 )
1226 if (showActualCall) {
1227 methodCall += diff(showActualCall, callArg, {
1228 omitAnnotationLines: true,
1229 })
1230 }
1231 else {
1232 methodCall += stringify(callArg)
1233 .split('\n')
1234 .map(line => ` ${line}`)
1235 .join('\n')
1236 }
1237
1238 methodCall += '\n'
1239 return methodCall
1240 })
1241 .join('\n')}`,
1242 )
1243 }
1244 msg += c.gray(
1245 `\n\nNumber of calls: ${c.bold(spy.mock.calls.length)}\n`,
1246 )
1247 return msg
1248}
1249
1250function formatReturns(
1251 spy: MockInstance,

Callers 1

JestChaiExpectFunction · 0.85

Calls 4

ordinalFunction · 0.90
diffFunction · 0.85
stringifyFunction · 0.85
getMockNameMethod · 0.80

Tested by

no test coverage detected