简体   繁体   中英

Log to terminal when QUnit test suite completes?

When my test suite completes, I need to output some stats, ie 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.

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:

在此输入图像描述 That's a weird error, I thought I was passing a callback function :-\\

Attempt 2:

在此输入图像描述 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:

在此输入图像描述 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

在此输入图像描述 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 :(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM