1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 21:50:00 -05:00

fix(std/testing): assertion diff color (#7499)

This commit is contained in:
Pig Fang 2020-09-16 18:42:51 +08:00 committed by GitHub
parent aa81bc73d9
commit aa657d6493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -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)

View file

@ -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",