I managed to come up with a workaround. Now the actual code I used is more complicated, but the idea is the same.
I added a global variable to the protractor configuration file with the name bail. Consider the following code at the top of the configuration file:
(function () {
global.bail = false;
})();
exports.config: { ...
The code above uses an IIFE expression (an expression with an immediate call expression) that defines a variable bailon the protractor object global(which will be available throughout the test).
Jasmine , expect, , ( Q). :
var q = require('q');
function check(actual) {
return {
sameAs: function(expected) {
var deferred = q.defer();
var expectation = {};
expect(actual).toBe(expected);
expectation.result = (actual === expected);
if ( expectation.result ) {
deferred.resolve(expectation);
}
else {
deferred.reject(expectation);
}
return deferred.promise;
}
};
}
module.exports = check;
bail , . :
var check = require('myAsyncWrappers');
describe('Test', function() {
it('should bail on next spec if expectation fails', function(done) {
var myValue = 123;
check(myValue).sameAs('123')
.then(function(expectation) {
console.log('Expectation was met');
})
.catch(function(expectation) {
console.log('Expectation was not met');
bail = true;
})
.finally(function() {
done();
});
});
});
, bail :
describe('Test', function() {
it('should be skipped due to bail being true', function(done) {
if ( bail ) {
console.log('Skipping spec due to previous failure');
done();
return;
}
});
});
, , protractor-fail-fast, , .
bail , . ( ), , , .