Skip to content

Commit e02ee4d

Browse files
committed
Match detailed error message
1 parent a10aadc commit e02ee4d

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

testing/snapshot.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ function getSnapshotNotMatchMessage(
354354
? diffStr(actualSnapshot, expectedSnapshot)
355355
: diff(actualSnapshot.split("\n"), expectedSnapshot.split("\n"));
356356
const diffMsg = buildMessage(diffResult, { stringDiff }).join("\n");
357-
const message = `Snapshot does not match:\n${diffMsg}`;
357+
const message =
358+
`Snapshot does not match:\n${diffMsg}\nTo update snapshots, run\n deno test --allow-read --allow-write [files]... -- --update\n`;
358359
return getErrorMessage(message, options);
359360
}
360361

@@ -859,13 +860,7 @@ export async function assertSnapshot(
859860
if (equal(actualSnapshot, expectedSnapshot)) {
860861
return;
861862
}
862-
const stringDiff = !_actual.includes("\n");
863-
const diffResult = stringDiff
864-
? diffStr(_actual, snapshot)
865-
: diff(_actual.split("\n"), snapshot.split("\n"));
866-
const diffMsg = buildMessage(diffResult, { stringDiff }).join("\n");
867-
const message =
868-
`Snapshot does not match:\n${diffMsg}\nTo update snapshots, run\n deno test --allow-read --allow-write [files]... -- --update\n`;
863+
869864
throw new AssertionError(
870865
getSnapshotNotMatchMessage(actualSnapshot, expectedSnapshot, options),
871866
);

0 commit comments

Comments
 (0)