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:
parent
e9f02c2314
commit
12e700bddf
4 changed files with 30 additions and 4 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
4
cli/tests/deno_test_unresolved_promise.out
Normal file
4
cli/tests/deno_test_unresolved_promise.out
Normal 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.
|
|
@ -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
|
||||||
|
|
15
cli/tests/test_unresolved_promise.js
Normal file
15
cli/tests/test_unresolved_promise.js
Normal 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");
|
||||||
|
},
|
||||||
|
});
|
Loading…
Reference in a new issue