Files
jasmine/src/core/SkipAfterBeforeAllErrorPolicy.js
Steve Gravrock 0b1385c3d3 Report start and end events for specs/suites that are skipped due to a beforeAll error
This is noisier, but it maintains compatibility with reporters that assume
(quite reasonably) that all specs and suites are either filtered out or
reported.
2021-12-11 12:34:23 -08:00

39 lines
1.3 KiB
JavaScript

getJasmineRequireObj().SkipAfterBeforeAllErrorPolicy = function(j$) {
function SkipAfterBeforeAllErrorPolicy(queueableFns) {
this.queueableFns_ = queueableFns;
this.skipping_ = false;
}
SkipAfterBeforeAllErrorPolicy.prototype.skipTo = function(lastRanFnIx) {
if (this.skipping_) {
return this.nextAfterAllAfter_(lastRanFnIx);
} else {
return lastRanFnIx + 1;
}
};
SkipAfterBeforeAllErrorPolicy.prototype.nextAfterAllAfter_ = function(i) {
for (
i++;
i < this.queueableFns_.length &&
this.queueableFns_[i].type !== 'afterAll';
i++
) {}
return i;
};
SkipAfterBeforeAllErrorPolicy.prototype.fnErrored = function(fnIx) {
if (this.queueableFns_[fnIx].type === 'beforeAll') {
this.skipping_ = true;
// Failures need to be reported for each contained spec. But we can't do
// that from here because reporting is async. This function isn't async
// (and can't be without greatly complicating QueueRunner). Mark the
// failure so that the code that reports the suite result (which is
// already async) can detect the failure and report the specs.
this.queueableFns_[fnIx].suite.hadBeforeAllFailure = true;
}
};
return SkipAfterBeforeAllErrorPolicy;
};