I am new to protractor and I am trying to figure out how to make the test/runner pause on failure. Ideally I would love to transition to the nodejs debugger but am open to any suggestion.
My use case is basically, when a test fails I would like to see what state the UI is in to help understand why the test failed.
Nick.
You can also add to the jasmine config, to stop when spec fails: (same as how protractor-screenshot-reporter works)
for jasmine 1:
onPrepare: function () {
exports.config = {
onPrepare: function () {
jasmine.getEnv().addReporter({
reportSpecResults: function (spec) {
if (!spec.results().passed()) {
spec.results().items_.forEach(function (v) {
console.log(v.trace.stack);
});
browser.pause();
}
}
});
}
}
}
for jasmine2:
onPrepare: function () {
jasmine.getEnv().addReporter({
specDone: function (spec) {
if (spec.status === 'failed') {
console.dir(spec.failedExpectations.length);
console.log(spec.failedExpectations[0].message);
console.log(spec.failedExpectations[0].stack);
browser.pause();
}
}
});
}
then by typing "repl" in the console you switch to interactive mode, so you can try out the protractor commands.
You can put browser to sleep after or before your expect
line to see what's going on.
browser.sleep(20000); // sleep 20 seconds
protractor now supports .pause()
method.
browser.pause()
Read the docs here: https://angular.github.io/protractor/#/api?view=Protractor.prototype.pause
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With