diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-04-27 13:40:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-27 14:40:03 +0200 |
commit | 03132e19da6c8e34e8100c6a57cd911b43900950 (patch) | |
tree | 014db77ed12f9ae882abba3c23c5f541461f03b4 /cli/tests | |
parent | d043a6d72cbf683c70f7eb4b9b3c09003afd2683 (diff) |
fix(test): handle dispatched exceptions from test functions (#18853)
Fixes #18852.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/test_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/testdata/test/report_error.out | 23 | ||||
-rw-r--r-- | cli/tests/testdata/test/report_error.ts | 6 |
3 files changed, 35 insertions, 0 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index 0e1a39deb..223c02e24 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -425,6 +425,12 @@ itest!(uncaught_errors { exit_code: 1, }); +itest!(report_error { + args: "test --quiet test/report_error.ts", + output: "test/report_error.out", + exit_code: 1, +}); + itest!(check_local_by_default { args: "test --quiet test/check_local_by_default.ts", output: "test/check_local_by_default.out", diff --git a/cli/tests/testdata/test/report_error.out b/cli/tests/testdata/test/report_error.out new file mode 100644 index 000000000..698550f97 --- /dev/null +++ b/cli/tests/testdata/test/report_error.out @@ -0,0 +1,23 @@ +running 2 tests from [WILDCARD]/report_error.ts +foo ... +Uncaught error from [WILDCARD]/report_error.ts FAILED +foo ... cancelled (0ms) +bar ... cancelled (0ms) + + ERRORS + +[WILDCARD]/report_error.ts (uncaught error) +error: Error: foo + reportError(new Error("foo")); + ^ + at [WILDCARD]/report_error.ts:2:15 +This error was not caught from a test and caused the test runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + + FAILURES + +[WILDCARD]/report_error.ts (uncaught error) + +FAILED | 0 passed | 3 failed ([WILDCARD]) + +error: Test failed diff --git a/cli/tests/testdata/test/report_error.ts b/cli/tests/testdata/test/report_error.ts new file mode 100644 index 000000000..56b6db26c --- /dev/null +++ b/cli/tests/testdata/test/report_error.ts @@ -0,0 +1,6 @@ +Deno.test("foo", () => { + reportError(new Error("foo")); + console.log(1); +}); + +Deno.test("bar", () => {}); |