From 12e700bddfad8c23f6b55baca4ca4afb8337af26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 14 Oct 2020 15:19:13 +0200 Subject: fix(test): return error when awaiting unresolved promise (#7968) This commit fixes test runner by awaitning "Deno.runTests()" call, which ensures proper error is returned when there's an unresolved promise that's being awaited. --- cli/tests/deno_test_unresolved_promise.out | 4 ++++ cli/tests/integration_tests.rs | 6 ++++++ cli/tests/test_unresolved_promise.js | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 cli/tests/deno_test_unresolved_promise.out create mode 100644 cli/tests/test_unresolved_promise.js (limited to 'cli/tests') diff --git a/cli/tests/deno_test_unresolved_promise.out b/cli/tests/deno_test_unresolved_promise.out new file mode 100644 index 000000000..cc4f2985e --- /dev/null +++ b/cli/tests/deno_test_unresolved_promise.out @@ -0,0 +1,4 @@ +Check [WILDCARD] +running 2 tests +test unresolved promise ... in promise +error: Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promise. diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 66a83a655..9dff74f25 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1646,6 +1646,12 @@ itest!(deno_test_no_check { output: "deno_test.out", }); +itest!(deno_test_unresolved_promise { + args: "test test_unresolved_promise.js", + exit_code: 1, + output: "deno_test_unresolved_promise.out", +}); + #[test] fn timeout_clear() { // https://github.com/denoland/deno/issues/7599 diff --git a/cli/tests/test_unresolved_promise.js b/cli/tests/test_unresolved_promise.js new file mode 100644 index 000000000..466b18864 --- /dev/null +++ b/cli/tests/test_unresolved_promise.js @@ -0,0 +1,15 @@ +Deno.test({ + name: "unresolved promise", + fn() { + return new Promise((_resolve, _reject) => { + console.log("in promise"); + }); + }, +}); + +Deno.test({ + name: "ok", + fn() { + console.log("ok test"); + }, +}); -- cgit v1.2.3