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

Function buildEqualErrorMessage

expect/_build_message.ts:27–48  ·  view source on GitHub ↗
(
  actual: T,
  expected: T,
  options: EqualErrorMessageOptions = {},
)

Source from the content-addressed store, hash-verified

25}
26
27export function buildEqualErrorMessage<T>(
28 actual: T,
29 expected: T,
30 options: EqualErrorMessageOptions = {},
31): string {
32 const { formatter = format, msg, summary = "Values are not equal." } =
33 options;
34 const msgPrefix = msg ? `${msg}: ` : "";
35 const actualString = formatter(actual);
36 const expectedString = formatter(expected);
37
38 let message = `${msgPrefix}${summary}`;
39
40 const stringDiff = isString(actual) && isString(expected);
41 const diffResult = stringDiff
42 ? diffStr(actual, expected)
43 : diff(actualString.split("\n"), expectedString.split("\n"));
44 const diffMsg = buildMessage(diffResult, { stringDiff }).join("\n");
45 message = `${message}\n${diffMsg}`;
46
47 return message;
48}
49
50export function buildNotEqualErrorMessage<T>(
51 actual: T,

Callers 3

triggerErrorFunction · 0.90
applyPropertyMatchersFunction · 0.90
assertEqualsFunction · 0.90

Calls 5

diffFunction · 0.90
formatterFunction · 0.85
diffStrFunction · 0.85
buildMessageFunction · 0.85
isStringFunction · 0.70

Tested by

no test coverage detected