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

testStart callback does not wait on returned Promise. #1374

Closed
jeberger opened this issue Feb 13, 2019 · 2 comments
Closed

testStart callback does not wait on returned Promise. #1374

jeberger opened this issue Feb 13, 2019 · 2 comments

Comments

@jeberger
Copy link
Contributor

Tell us about your runtime:

  • QUnit version: 2.7.1
  • What environment are you running QUnit in? (e.g., browser, Node): node v10.12.0
  • How are you running QUnit? (e.g., script, testem, Grunt): using the qunit script (eg. ./node_modules/qunit/bin/qunit)

What are you trying to do?

Code that reproduces the problem:

"use strict";

QUnit.testStart (() => {
   console.log ("waiting");
   return new Promise ((resolve, reject) => setTimeout (resolve, 5000))
      .then (() => console.log ("proceeding"));
});
QUnit.testDone (() => console.log ("done"));

QUnit.test ("test", (assert) => {
   console.log ("inside the test");
   assert.equal (2+2, 4);
});

Command line:

./node_modules/qunit/bin/qunit test.js

What did you expect to happen?

According to the documentation, QUnit should wait for the promise before proceeding, so I expected to see the traces:

waiting
proceeding
inside the test
done

in that order with a 5s delay between waiting and proceeding.

What actually happened?

The test proceeded immediately without waiting for the promise. I got the traces:

waiting
inside the test
done
proceeding

with the expected 5s delay before the proceeding trace, but by that time the test has already run.

@rwjblue
Copy link
Contributor

rwjblue commented Feb 13, 2019

  • QUnit version: 2.7.1

Per History.md supporting async in these callbacks was not landed until 2.8.0 (by way of #1307).

Can you update and re-run your test?

@jeberger
Copy link
Contributor Author

Upgrading QUnit fixes the issue. Thanks for the prompt response.

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

No branches or pull requests

2 participants