protractor icon indicating copy to clipboard operation
protractor copied to clipboard

onComplete does not allow for a blocking callback

Open Jeff-Symphony opened this issue 11 years ago • 3 comments

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);
    }
};

Jeff-Symphony avatar Mar 18 '15 21:03 Jeff-Symphony

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

  1. Improve docs about this
  2. Consider making onComplete wait for promises (this will require changes to all framework runners)

juliemr avatar Mar 18 '15 22:03 juliemr

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?

vikasgahlaut avatar Dec 22 '15 16:12 vikasgahlaut

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.

vikas2future avatar Jun 21 '16 18:06 vikas2future