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

Function assertDiffMessage

assert/unstable_equals_test.ts:10–29  ·  view source on GitHub ↗
(a: unknown, b: unknown, expected: string)

Source from the content-addressed store, hash-verified

8import { disposableStack } from "../internal/_testing.ts";
9
10function assertDiffMessage(a: unknown, b: unknown, expected: string) {
11 const err = assertThrows(() => assertEquals(a, b), AssertionError);
12 // TODO(lionel-rowe): re-spell `fullExpectedMessage` indentation once https://github.com/denoland/std/issues/6830
13 // is fixed
14 const fullExpectedMessage = dedent`
15 Values are not equal.
16
17
18 [Diff] Actual / Expected
19
20
21 ${expected}
22 `;
23 assertEquals(
24 // TODO(lionel-rowe): compare full messages without trimming once https://github.com/denoland/std/issues/6830 and
25 // https://github.com/denoland/std/issues/6831 are fixed
26 stripAnsiCode(err.message).trimEnd(),
27 fullExpectedMessage,
28 );
29}
30
31Deno.test(`assertEquals() truncates unchanged lines of large diffs when "${DIFF_CONTEXT_LENGTH}" is set`, async (t) => {
32 using stack = disposableStack();

Callers 1

Calls 4

assertThrowsFunction · 0.90
assertEqualsFunction · 0.90
stripAnsiCodeFunction · 0.90
dedentFunction · 0.85

Tested by

no test coverage detected