node-qunit icon indicating copy to clipboard operation
node-qunit copied to clipboard

Unable to test asynchronous code

Open ArnaudBuchholz opened this issue 6 years ago • 1 comments

Guys,

I am fully aware of the asynchronous helpers built in QUnit and I use them whenever the test is asynchronous. However, the problem I am dealing with is the code itself that is asynchronous.

For instance:

testrunner.run({
    code: 'code-to-test.js',
    tests: 'unit-tests.js'
})

In that example, code-to-test.js is actually loading asynchronous dependencies and I would like QUnit to wait before running the corresponding unit tests.

Checking node-qunit code, I would like child.js's _require function to be asynchronous.

Thinking about the way we could tell the function that it has to wait, I was thinking that if the loaded module exports a promise, we could wait for it to be resolved before continuing the load.

Any thoughts?

  • Arnaud

ArnaudBuchholz avatar May 21 '19 13:05 ArnaudBuchholz

@ArnaudBuchholz Note that the main qunit package now has a CLI as well, which is more actively maintained and might suit your needs?

Krinkle avatar Jun 19 '19 01:06 Krinkle