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

Function getSnapshotNotMatchMessage

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

Source from the content-addressed store, hash-verified

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