javascriptember-cliqunitember-qunittestem

Log to terminal when QUnit test suite completes?


When my test suite completes, I need to output some stats, i. e. meta info about tests collected during test execution.

I'm trying this:

QUnit.done(() => console.log("some meta info here"))

This works when I run tests in the browser.

But when I run tests in the terminal, the console.log output is not displayed.

There's probably some debug flag, but it will enable all console.log messages and pollute the output greatly.

Instead, I need to output one specific message to the terminal, so that it's logged to CI.

PS console.log messages sent during test execution seem to make it into the terminal successfully.

PPS Using QUnit in an Ember CLI app, against Chrome headless.


Solution

  • This was a tricky one, as I've never had a need to interact with QUnit like, this, but here are my findings each step of the way:

    Attempt 1:

    enter image description here That's a weird error, I thought I was passing a callback function :-\

    Attempt 2:

    enter image description here After looking up the documentation for Qunit.log, I could see I was using it wrong. Switching to console.log shows the beginning message -- but not the ending message.

    Attempt 3:

    enter image description here moduleDone will print something at the end -- but it also prints for every time you use the word module (after everything inside finishes running). So, I guess as a hack if QUnit.done never ends up working, you could keep track of the number of modules started, and modules done, make sure every started modules completes, and if that number is 0 at the end, your test suite is done?

    Attempt 4

    enter image description here Turns out, this is only actually helpful for if you want to know the outermost module is done, cause it seems like multiple tests don't run in parallel (which is probably better anyway for test stability).

    Attempt 5

    https://github.com/qunitjs/qunit/issues/1308

    It looks like an issue with the testem adapter :(