Returned pending Promise from `QUnit.done` causes browser to prematurely disconnect

This issue has been tracked since 2022-08-10.

Summary
When using Testem in ci mode, if the QUnit.done callback returns a pending Promise, the browser will prematurely disconnect preventing the rest of the registered callbacks from running in QUnit's queue. A very simple example:

QUnit.done(function() {
  return new Promise((resolve) => setTimeout(resolve, 1000));
});

Reproduction Steps

  1. Generate a new Ember app.
  2. Add the following to tests/test-helper.js:
QUnit.done(function doneCallbackOne() {
  debugger;
  return new Promise((resolve) => setTimeout(resolve, 1000));
});

QUnit.done(function doneCallbackTwo() {
  debugger;
  return new Promise((resolve) => setTimeout(resolve, 1000));
});

QUnit.done(function doneCallbackThree() {
  debugger;
  return new Promise((resolve) => setTimeout(resolve, 1000));
});
  1. Run ember test with the ability to inspect browser output. A quick way to do this is to remove the --headless option and add --auto-open-devtools-for-tabs in testem.js.
  2. Note that the browser will disconnect as soon as doneCallbackOne() is invoked. doneCallbackTwo() and doneCallbackThree() never execute.

Additional Details
The issue doesn't occur when running ember test --server as the browser session persists after the test execution completes and QUnit is able to run all of its registered callbacks.

This presents a huge issue for tooling such as ember-a11y-testing and ember-cli-code-coverage, which expect setup to occur in the done handler. In the following example, any registered callbacks defined after the ember-cli-code-coverage setup, is never invoked.

QUnit.done(async function() {
  forceModulesToBeLoaded();
  await sendCoverage();
});
More Details About Repo
Owner Name testem
Repo Name testem
Full Name testem/testem
Language JavaScript
Created Date 2011-07-12
Updated Date 2022-11-22
Star Count 2953
Watcher Count 71
Fork Count 409
Issue Count 127

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date