Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to know that nodeunit has finished all tests?

I need to run some code after nodeunit successfully passed all tests. I'm testing some Firebase wrappers and Firebase reference blocks exiting nodeunit after all test are run.

I am looking for some hook or callback to run after all unit tests are passed. So I can terminate Firebase process in order nodeunit to be able to exit.

like image 457
webduvet Avatar asked Dec 02 '25 07:12

webduvet


1 Answers

Didn't found a right way to do it.

There is my temporary solution:

//Put a *LAST* test to clear all if needed:
exports.last_test = function(test){
    //do_clear_all_things_if_needed();
    setTimeout(process.exit, 500); // exit in 500 milli-seconds    
    test.done(); 
} 

In my case, this is used to make sure DB connection or some network connect get killed any way. The reason it works is because nodeunit run tests in series.

It's not the best, even not the good way, just to let the test exit.

For nodeunit 0.9.0

like image 160
Andrew_1510 Avatar answered Dec 03 '25 22:12

Andrew_1510



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!