Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): return error when awaiting unresolved promise #7968

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cli/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ pub fn render_test_file(
json!({ "failFast": fail_fast, "reportToConsole": !quiet, "disableLog": quiet })
};

let run_tests_cmd = format!(
"// @ts-ignore\nDeno[Deno.internal].runTests({});\n",
test_file.push_str("// @ts-ignore\n");

test_file.push_str(&format!(
"await Deno[Deno.internal].runTests({});\n",
options
);
test_file.push_str(&run_tests_cmd);
));

test_file
}
Expand Down
4 changes: 4 additions & 0 deletions cli/tests/deno_test_unresolved_promise.out
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions cli/tests/test_unresolved_promise.js
Original file line number Diff line number Diff line change
@@ -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");
},
});