1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 12:58:54 -05:00

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.
This commit is contained in:
Bartek Iwańczuk 2020-10-14 15:19:13 +02:00 committed by GitHub
parent e9f02c2314
commit 12e700bddf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 4 deletions

View file

@ -82,11 +82,12 @@ pub fn render_test_file(
json!({ "failFast": fail_fast, "reportToConsole": !quiet, "disableLog": quiet }) json!({ "failFast": fail_fast, "reportToConsole": !quiet, "disableLog": quiet })
}; };
let run_tests_cmd = format!( test_file.push_str("// @ts-ignore\n");
"// @ts-ignore\nDeno[Deno.internal].runTests({});\n",
test_file.push_str(&format!(
"await Deno[Deno.internal].runTests({});\n",
options options
); ));
test_file.push_str(&run_tests_cmd);
test_file test_file
} }

View file

@ -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.

View file

@ -1646,6 +1646,12 @@ itest!(deno_test_no_check {
output: "deno_test.out", 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] #[test]
fn timeout_clear() { fn timeout_clear() {
// https://github.com/denoland/deno/issues/7599 // https://github.com/denoland/deno/issues/7599

View file

@ -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");
},
});