You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you assert an error class but a different error was thrown, the message for assertThrows ends with ', but was "ExampleError".'. the message for assertThrowsAsync has a similar message except instead of "was" it says "got" and it always shows the actual as being "Error" incorrectly. I would expect all the tests to pass if assertThrowsAsync was working correctly.
I have deno 1.11.0 installed. Below is a minimum reproduction path. The assertThrows tests and the assertThrowsAsync test pass, but the 2 tests for what error assertThrowsAsync should throw fail.
import{AssertionError,assertThrows,assertThrowsAsync,}from"https://deno.land/[email protected]/testing/asserts.ts";classExampleErrorextendsError{}classOtherErrorextendsError{}Deno.test("assertThrows",()=>{assertThrows(()=>{thrownewExampleError("failed");},ExampleError,"fail",);});Deno.test("assertThrows error",()=>{assertThrows(()=>assertThrows(()=>{thrownewExampleError("failed");},OtherError,"fail",),AssertionError,'Expected error to be instance of "OtherError", but was "ExampleError".',);});Deno.test("assertThrowsAsync",async()=>{awaitassertThrowsAsync(()=>Promise.reject(newExampleError("failed")),ExampleError,"fail",);});Deno.test("assertThrowsAsync promise rejected",async()=>{awaitassertThrowsAsync(()=>assertThrowsAsync(()=>Promise.reject(newExampleError("failed")),OtherError,"fail",),AssertionError,'Expected error to be instance of "OtherError", but was "ExampleError".',);});Deno.test("assertThrowsAsync error thrown in async function",async()=>{awaitassertThrowsAsync(()=>assertThrowsAsync(async()=>{awaitPromise.resolve();thrownewExampleError("failed");},OtherError,"fail",),AssertionError,'Expected error to be instance of "OtherError", but was "ExampleError".',);});
$ deno test example_test.ts
running 5 tests from file:///home/kyle/Projects/deno/mock/example_test.ts
test assertThrows ... ok (2ms)
test assertThrows error ... ok (2ms)
test assertThrowsAsync ... ok (1ms)
test assertThrowsAsync promise rejected ... FAILED (1ms)
test assertThrowsAsync error thrown in async function ... FAILED (2ms)
failures:
assertThrowsAsync promise rejected
AssertionError: Expected error message to include "Expected error to be instance of "OtherError", but was "ExampleError".", but got "Expected error to be instance of "OtherError", but got "Error".".
at assertThrowsAsync (https://deno.land/[email protected]/testing/asserts.ts:632:13)
at async file:///home/kyle/Projects/deno/mock/example_test.ts:44:3
at async asyncOpSanitizer (deno:runtime/js/40_testing.js:21:9)
at async resourceSanitizer (deno:runtime/js/40_testing.js:58:7)
at async exitSanitizer (deno:runtime/js/40_testing.js:85:9)
at async runTest (deno:runtime/js/40_testing.js:199:7)
at async Object.runTests (deno:runtime/js/40_testing.js:244:7)
at async file:///home/kyle/Projects/deno/mock/$deno$test.js:1:1
assertThrowsAsync error thrown in async function
AssertionError: Expected error message to include "Expected error to be instance of "OtherError", but was "ExampleError".", but got "Expected error to be instance of "OtherError", but got "Error".".
at assertThrowsAsync (https://deno.land/[email protected]/testing/asserts.ts:632:13)
at async file:///home/kyle/Projects/deno/mock/example_test.ts:57:3
at async asyncOpSanitizer (deno:runtime/js/40_testing.js:21:9)
at async resourceSanitizer (deno:runtime/js/40_testing.js:58:7)
at async exitSanitizer (deno:runtime/js/40_testing.js:85:9)
at async runTest (deno:runtime/js/40_testing.js:199:7)
at async Object.runTests (deno:runtime/js/40_testing.js:244:7)
at async file:///home/kyle/Projects/deno/mock/$deno$test.js:1:1
failures:
assertThrowsAsync promise rejected
assertThrowsAsync error thrown in async function
test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out (45ms)
The text was updated successfully, but these errors were encountered:
When you assert an error class but a different error was thrown, the message for assertThrows ends with ', but was "ExampleError".'. the message for assertThrowsAsync has a similar message except instead of "was" it says "got" and it always shows the actual as being "Error" incorrectly. I would expect all the tests to pass if assertThrowsAsync was working correctly.
I have deno 1.11.0 installed. Below is a minimum reproduction path. The assertThrows tests and the assertThrowsAsync test pass, but the 2 tests for what error assertThrowsAsync should throw fail.
The text was updated successfully, but these errors were encountered: