UNPKG

yachr

Version:

Yet another cucumber html reporter

84 lines 4.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FeatureSummary = void 0; /** * A summary of all scenarios in a Feature. * Aggregates all scenarios in the feature to report the total number * of passing/failing scenarios within the feature */ class FeatureSummary { constructor() { this.featureName = ''; this.featureDescription = ''; this.featureKeyword = ''; // Ability | Feature this.passingScenarios = []; this.failingScenarios = []; this.ambiguousScenarios = []; this.pendingScenarios = []; this.undefinedScenarios = []; /** Comma separated string of all tags on the feature */ this.tags = ''; } /** The total number of Scenarios that are ambiguously defined for the Feature */ get ambiguous() { return this.ambiguousScenarios.length; } /** The total number of Scenarios that have failed in this Feature */ get failed() { return this.failingScenarios.length; } /** The total number of Scenarios that are have no step definition (and thus marked as undefined) */ get undefined() { return this.undefinedScenarios.length; } /** The total number of Scenarios that are not implemented (and thus marked as pending) */ get pending() { return this.pendingScenarios.length; } /** The total number of Scenarios that have passed in this Feature */ get passed() { return this.passingScenarios.length; } /** All Scenarios in this Feature */ get total() { return this.ambiguous + this.failed + this.undefined + this.pending + this.passed; } /** Whether the Feature has at least one ambiguous Scenario */ get hasAmbiguous() { return this.ambiguous > 0; } /** Whether the Feature has at least one failed Scenario */ get hasFailed() { return this.failed > 0; } /** Whether the Feature has at least one undefined Scenario */ get hasUndefined() { return this.undefined > 0; } /** Whether the Feature has at least one pending Scenario */ get hasPending() { return this.pending > 0 || this.hasNoScenarios; } get hasNoScenarios() { return this.total === 0; } /** Whether the Feature has passed due to all Scenarios passing */ get isPassed() { return this.passed > 0 && this.passed === this.total; } /** Updates the Feature summary using information gathered in the Scenario Summary */ aggregateScenario(scenario) { // As per view-report-summary.feature // The status of a Scenario behaves like a hierarchy that rolls up. // The scenario status will be the 'worst' status of its child steps as follows: // ambiguous, failed, undefined, pending, passed // Although a step can be skipped, a scenario cannot. // - Ambiguous is the worst because it is similar to a compile erorr. There are // two or more implementations that match one step, and the test simply can't be run. // - Failed is next because a step has been implemented, and failed, which is unexpected. // - Undefined is then next, because no implementation has been put together. // - Pending is where the implementation exists, but returns the string pending. // - Finally, if all steps pass, then the scenario passes. if (scenario.hasAmbiguous) { this.ambiguousScenarios.push(scenario); } else if (scenario.hasFailed) { this.failingScenarios.push(scenario); } else if (scenario.hasUndefined) { this.undefinedScenarios.push(scenario); } else if (scenario.hasPending) { this.pendingScenarios.push(scenario); } else if (scenario.isPassed) { this.passingScenarios.push(scenario); } else { throw new Error('Scenario cannot be aggregated. Please raise a GitHub issue with the Yachr Team'); } } } exports.FeatureSummary = FeatureSummary; //# sourceMappingURL=featureSummary.js.map