diff options
Diffstat (limited to 'std/testing')
-rw-r--r-- | std/testing/asserts.ts | 9 | ||||
-rw-r--r-- | std/testing/asserts_test.ts | 2 | ||||
-rw-r--r-- | std/testing/diff.ts | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts index d3f8bb678..ce7214998 100644 --- a/std/testing/asserts.ts +++ b/std/testing/asserts.ts @@ -1,4 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +/** This module is browser compatible. Do not rely on good formatting of values + * for AssertionError messages in browsers. */ + import { red, green, white, gray, bold } from "../fmt/colors.ts"; import diff, { DiffType, DiffResult } from "./diff.ts"; @@ -17,7 +20,7 @@ export class AssertionError extends Error { } function format(v: unknown): string { - let string = Deno.inspect(v); + let string = globalThis.Deno ? Deno.inspect(v) : String(v); if (typeof v == "string") { string = `"${string.replace(/(?=["\\])/g, "\\")}"`; } @@ -254,7 +257,7 @@ export function assertStrContains( ): void { if (!actual.includes(expected)) { if (!msg) { - msg = `actual: "${actual}" expected to contains: "${expected}"`; + msg = `actual: "${actual}" expected to contain: "${expected}"`; } throw new AssertionError(msg); } @@ -286,7 +289,7 @@ export function assertArrayContains( return; } if (!msg) { - msg = `actual: "${actual}" expected to contains: "${expected}"`; + msg = `actual: "${actual}" expected to contain: "${expected}"`; msg += "\n"; msg += `missing: ${missing}`; } diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts index 14eabca61..fb25d46cf 100644 --- a/std/testing/asserts_test.ts +++ b/std/testing/asserts_test.ts @@ -169,7 +169,7 @@ test("testingAssertStringContainsThrow", function (): void { } catch (e) { assert( e.message === - `actual: "Denosaurus from Jurassic" expected to contains: "Raptor"` + `actual: "Denosaurus from Jurassic" expected to contain: "Raptor"` ); assert(e instanceof AssertionError); didThrow = true; diff --git a/std/testing/diff.ts b/std/testing/diff.ts index 97baa089f..da1e827ac 100644 --- a/std/testing/diff.ts +++ b/std/testing/diff.ts @@ -1,4 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +/** This module is browser compatible. */ + interface FarthestPoint { y: number; id: number; |