From f1d04d640344403949ef709d9e18553815b2182b Mon Sep 17 00:00:00 2001 From: Ian Bull Date: Mon, 26 Aug 2024 01:27:49 -0400 Subject: [PATCH] refactor(expect): align additional error messages (#5811) --- expect/_equal.ts | 4 ++-- expect/expect.ts | 6 +++--- expect/test.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/expect/_equal.ts b/expect/_equal.ts index 68ef336ad..f316db2b3 100644 --- a/expect/_equal.ts +++ b/expect/_equal.ts @@ -103,11 +103,11 @@ export function equal(c: unknown, d: unknown, options?: EqualOptions): boolean { } if (a instanceof WeakMap || b instanceof WeakMap) { if (!(a instanceof WeakMap && b instanceof WeakMap)) return false; - throw new TypeError("cannot compare WeakMap instances"); + throw new TypeError("Cannot compare WeakMap instances"); } if (a instanceof WeakSet || b instanceof WeakSet) { if (!(a instanceof WeakSet && b instanceof WeakSet)) return false; - throw new TypeError("cannot compare WeakSet instances"); + throw new TypeError("Cannot compare WeakSet instances"); } if (seen.get(a) === b) { return true; diff --git a/expect/expect.ts b/expect/expect.ts index ac0063d8a..c999b499f 100644 --- a/expect/expect.ts +++ b/expect/expect.ts @@ -154,7 +154,7 @@ export function expect( if (name === "resolves") { if (!isPromiseLike(value)) { - throw new AssertionError("expected value must be Promiselike"); + throw new AssertionError("Expected value must be PromiseLike"); } isPromised = true; @@ -163,13 +163,13 @@ export function expect( if (name === "rejects") { if (!isPromiseLike(value)) { - throw new AssertionError("expected value must be a PromiseLike"); + throw new AssertionError("Expected value must be a PromiseLike"); } value = value.then( (value) => { throw new AssertionError( - `Promise did not reject. resolved to ${value}`, + `Promise did not reject: resolved to ${value}`, ); }, (err) => err, diff --git a/expect/test.ts b/expect/test.ts index 88b1c2728..68912aecd 100644 --- a/expect/test.ts +++ b/expect/test.ts @@ -10,12 +10,12 @@ Deno.test("expect().resolves.toEqual()", async () => { assertThrows( () => expect(42).resolves.toEqual(42), AssertionError, - "expected value must be Promiselike", + "Expected value must be PromiseLike", ); assertThrows( () => expect(null).resolves.toEqual(42), AssertionError, - "expected value must be Promiselike", + "Expected value must be PromiseLike", ); }); @@ -26,12 +26,12 @@ Deno.test("expect().rejects.toEqual()", async () => { assertThrows( () => expect(42).rejects.toEqual(42), AssertionError, - "expected value must be a PromiseLike", + "Expected value must be a PromiseLike", ); await assertRejects( () => expect(Promise.resolve(42)).rejects.toEqual(42), AssertionError, - "Promise did not reject. resolved to 42", + "Promise did not reject: resolved to 42", ); });