diff options
Diffstat (limited to 'std/testing/asserts.ts')
-rw-r--r-- | std/testing/asserts.ts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts index b1164090d..2a1358143 100644 --- a/std/testing/asserts.ts +++ b/std/testing/asserts.ts @@ -394,7 +394,7 @@ export function assertThrows<T = void>( if (e instanceof Error === false) { throw new AssertionError("A non-Error object was thrown."); } - if (ErrorClass && !(Object.getPrototypeOf(e) === ErrorClass.prototype)) { + if (ErrorClass && !(e instanceof ErrorClass)) { msg = `Expected error to be instance of "${ErrorClass.name}", but was "${ e.constructor.name }"${msg ? `: ${msg}` : "."}`; @@ -438,7 +438,7 @@ export async function assertThrowsAsync<T = void>( if (e instanceof Error === false) { throw new AssertionError("A non-Error object was thrown or rejected."); } - if (ErrorClass && !(Object.getPrototypeOf(e) === ErrorClass.prototype)) { + if (ErrorClass && !(e instanceof ErrorClass)) { msg = `Expected error to be instance of "${ErrorClass.name}", but got "${ e.name }"${msg ? `: ${msg}` : "."}`; |