I have the following reporters in the protractor.conf file:
var promise1 = new Promise(function (resolve) {
reporter1.afterLaunch(resolve.bind(this, exitCode));
});
var promise2 = new Promise(function (resolve) {
reporter2.afterLaunch(resolve.bind(this, exitCode));
});
return Promise.all([promise1, promise2]);
Each of the above reporters have their own afterlaunch that would be expected to execute once the afterlaunch in the ptor.conf file is executed.
This is a part of the continuous integration job in Jenkins. So what's happening is that the promise resolves so the exit code of the process becomes 0, even when a test fails hence overwriting the exit code of the job. So even though its a legit failure the jenkins shows the entire job as PASSED. I need to preserve the original value of exitCode
that is being passed to the above reports for the jenkins job to function as expected. How can we prevent this?
assuming
exitCode
is aNumber
theresolve.bind(this, exitCode)
returns a function whose first parameter is bound to the value ofexitCode
at the time those vars (promise1 and promise2) are declaredso any changes to exitCode between the time the promise is created and when the reporter1.afterLaunch callback gets fired will not be reflected in the value those promises resolve to,
i.e. assuming exitCode is zero when the promises are created, then the resolved value will be zero regardless of what exitCode is changed to
On the other hand
or
will resolve to the current value of exitCode