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

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

Open
drewlee opened this issue Aug 10, 2022 · 3 comments

Comments

@drewlee
Copy link

drewlee commented Aug 10, 2022

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();
});
@blb451
Copy link

blb451 commented May 2, 2023

@drewlee Were you eventually able to resolve this?

@drewlee
Copy link
Author

drewlee commented May 2, 2023

@blb451 Unfortunately not. We ended up using QUnit.on('runEnd', () => {}) as a workaround, instead of QUnit.done.

@blb451
Copy link

blb451 commented May 2, 2023

@drewlee Thanks very much for the response! Glad to hear you were able to find a workaround 👌 I was able to get past my issue the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants