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

Function getSnapshotNotMatchMessage

testing/_snapshot_utils.ts:93–106  ·  view source on GitHub ↗
(
  actualSnapshot: string,
  expectedSnapshot: string,
  options: SnapshotOptions,
)

Source from the content-addressed store, hash-verified

91}
92
93export function getSnapshotNotMatchMessage(
94 actualSnapshot: string,
95 expectedSnapshot: string,
96 options: SnapshotOptions,
97) {
98 const stringDiff = !actualSnapshot.includes("\n");
99 const diffResult = stringDiff
100 ? diffStr(actualSnapshot, expectedSnapshot)
101 : diff(actualSnapshot.split("\n"), expectedSnapshot.split("\n"));
102 const diffMsg = buildMessage(diffResult, { stringDiff }).join("\n");
103 const message =
104 `Snapshot does not match:\n${diffMsg}\nTo update snapshots, run\n deno test --allow-read --allow-write [files]... -- --update\n`;
105 return getErrorMessage(message, options);
106}
107
108// TODO (WWRS): Remove this when we drop support for Deno 1.x
109export const LINT_SUPPORTED = !Deno.version.deno.startsWith("1.");

Callers 2

assertInlineSnapshotFunction · 0.90
assertSnapshotFunction · 0.90

Calls 5

diffFunction · 0.90
diffStrFunction · 0.85
buildMessageFunction · 0.85
getErrorMessageFunction · 0.85
includesMethod · 0.80

Tested by

no test coverage detected