diff options
author | Pig Fang <g-plane@hotmail.com> | 2020-09-16 18:42:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-16 12:42:51 +0200 |
commit | aa657d6493cb0f36a5e2aa29e6352c9a9991ad2b (patch) | |
tree | e200264ee0ef29c12da0d584994899d9623e3fb1 /std/testing | |
parent | aa81bc73d96729f6593d55d2c1e66000e115dfe4 (diff) |
fix(std/testing): assertion diff color (#7499)
Diffstat (limited to 'std/testing')
-rw-r--r-- | std/testing/asserts.ts | 6 | ||||
-rw-r--r-- | std/testing/asserts_test.ts | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts index b7377c1bc..a3f0c1338 100644 --- a/std/testing/asserts.ts +++ b/std/testing/asserts.ts @@ -21,13 +21,13 @@ export class AssertionError extends Error { export function _format(v: unknown): string { let string = globalThis.Deno - ? Deno.inspect(v, { + ? stripColor(Deno.inspect(v, { depth: Infinity, sorted: true, trailingComma: true, compact: false, iterableLimit: Infinity, - }) + })) : String(v); if (typeof v == "string") { string = `"${string.replace(/(?=["\\])/g, "\\")}"`; @@ -303,7 +303,7 @@ export function assertStrictEquals( } /** - * Make an assertion that `actual` and `expected` are not strictly equal. + * Make an assertion that `actual` and `expected` are not strictly equal. * If the values are strictly equal then throw. * ```ts * assertNotStrictEquals(1, 1) diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts index f8a600d77..4840bcf53 100644 --- a/std/testing/asserts_test.ts +++ b/std/testing/asserts_test.ts @@ -336,8 +336,10 @@ const createHeader = (): string[] => [ "", ]; -const added: (s: string) => string = (s: string): string => green(bold(s)); -const removed: (s: string) => string = (s: string): string => red(bold(s)); +const added: (s: string) => string = (s: string): string => + green(bold(stripColor(s))); +const removed: (s: string) => string = (s: string): string => + red(bold(stripColor(s))); Deno.test({ name: "pass case", |