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

Function printReceivedStringContainExpectedSubstring

packages/expect/src/print.ts:21–30  ·  view source on GitHub ↗
(
  received: string,
  start: number,
  length: number, // not end
)

Source from the content-addressed store, hash-verified

19const printSubstring = (val: string): string => val.replaceAll(/"|\\/g, '\\$&');
20
21export const printReceivedStringContainExpectedSubstring = (
22 received: string,
23 start: number,
24 length: number, // not end
25): string =>
26 RECEIVED_COLOR(
27 `"${printSubstring(received.slice(0, start))}${INVERTED_COLOR(
28 printSubstring(received.slice(start, start + length)),
29 )}${printSubstring(received.slice(start + length))}"`,
30 );
31
32export const printReceivedStringContainExpectedResult = (
33 received: string,

Callers 4

messageFunction · 0.90
toMatchFunction · 0.90
formatReceivedFunction · 0.90

Calls 1

printSubstringFunction · 0.85

Tested by

no test coverage detected