onComplete does not allow for a blocking callback
I'm trying to implement an asynchronous action (Nodemailer) during the onComplete of my test config. I found that while the action starts, onComplete would finish and kill the runner before the action completed.
In order to get onComplete working for me using a deferred promise, I needed to modify the lib/framework/jasmine.js as such:
jasmineNodeOpts.onComplete = function(jasmineRunner, log) {
try {
if (originalOnComplete) {
originalOnComplete(jasmineRunner, log).then(resolveOnComplete);
}else{
resolveOnComplete();
}
function resolveOnComplete(){
resolve({
failedCount: jasmineRunner.results().failedCount,
specResults: testResult
});
}
} catch (err) {
reject(err);
}
};
You're right, onComplete was never set up to wait to return a promise, and is not documented and having that option. It's confusing because onPrepare and onCleanUp can return a promise and it will wait.
We should
- Improve docs about this
- Consider making
onCompletewait for promises (this will require changes to all framework runners)
Any updates on this issue. I am also trying to use nodemailer in onComplete event but it is not working or is there any workaround?
Hi All, We are using jasmine-reporters for generating both HTML as well as XML reports. However we have written a custom dot net console application to take the XML reports generated and write it back to Microsoft Test Manager. If i try to invoke a console application within the IT block of a spec file it invokes fine. However when we try to invoke the console application from OnComplete event(as XML reports would be generated by now) in conf.js it is not invoking at all. Kindly advise.