Prevent transporter leaving before completing the jasmine replica

I created a jasmine replicator that does a slow async task, but the protractor goes away before the reporter finishes. How to make the protractor wait for the slow reporter?

In my reporter, a slow task is simulated setTimeout

:

// SlowReporter.js
SlowReporter.prototype.reportRunnerResults = function() {
    var p = q.defer();
    setTimeout(function() {
        console.log("Slow reporting op finished");
        p.resolve();
    }, 10000);
    return p.promise;
};

      

But, when I plug it in,

// protractor.conf.js
onPrepare: function() {
    jasmine.getEnv().addReporter(new SlowReporter());
}

      

.. exits the protractor before completing the slow task. The protractor doesn't seem to respect the promise returned by the reporter.

Note that I am not asking how to make the protractor wait in an asynchronous test , but how to make the protractor wait for the jasmine reporter after the tests have finished.

+3


source to share


1 answer


FFR is solved by defining a method .completed()

in SlowReporter

that returns a promise that is resolved when the reporter ends; then protractor.spec.js

return that promise to onCleanUp()

. Only works with protractor> = 1.1.0.



Open for better answer / approaches.

0


source







All Articles