UNPKG

yachr

Version:

Yet another cucumber html reporter

91 lines 4.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ScenarioSummary = void 0; const resultStatus_1 = require("../reporter/resultStatus"); /** * A summary of all steps in a Gherkin Scenario as reported by the Cucumber Test Report. * Summarises all steps into a single aggregated summary */ class ScenarioSummary { constructor() { // Reports the total number of steps in the Scenario that have passed, failed, etc. /** The total number of steps that have passed for this Scenario */ this.passed = 0; /** The total number of steps that have failed for this Scenario */ this.failed = 0; /** The total number of steps that are not implemented (and thus marked as undefined) */ this.undefined = 0; /** The number of step that are not fully implemented and only return pending */ this.pending = 0; /** The nuber of steps that are ambiguous, preventing the Cucumber Test runner from running the step */ this.ambiguous = 0; /** The total number of steps that were skipped */ this.skipped = 0; this.steps = []; this.totalDuration = 0; this.scenarioName = ''; this.scenarioDescription = ''; this.scenarioKeyword = ''; /** All tags on the scenario as a comma separated list */ this.tags = ''; } /** All steps in the scenario */ get total() { return this.passed + this.failed + this.undefined + this.pending + this.ambiguous + this.skipped; } /** Whether the Scenario has at least one ambiguously defined step definition */ get hasAmbiguous() { return this.ambiguous > 0; } /** Whether the Scenario has at least one failed step */ get hasFailed() { return this.failed > 0; } /** Whether the Scenario has at least one undefined step */ get hasUndefined() { return this.undefined > 0 || // Undefined if we have an undefined step this.hasNoSteps; // Or if we have no steps at all } /** Whether the Scenario has at least one pending step */ get hasPending() { return this.pending > 0; } /** Whether the Scenario has passed due to all steps passing */ get isPassed() { return this.passed === this.total; } get hasNoSteps() { return this.total === 0; } /** * Updates the summary based on the raw cucumber report step status. * Performs the base level summarisation of the report at the lowest leaf * of the report tree (the Step) * @param result The Step result from the raw Cucumber report * @param hidden Some steps are hidden eg BeforeAll steps. We don't count them in the totals, except for duration */ aggregateStep(result, hidden) { this.totalDuration += (isNaN(result.duration) ? 0 : result.duration); // We don't count the hidden steps, but track their time above if (hidden) return; // Switch case on status switch (result.status) { case resultStatus_1.ResultStatus.passed: this.passed++; break; case resultStatus_1.ResultStatus.failed: this.failed++; break; case resultStatus_1.ResultStatus.undefined: this.undefined++; break; case resultStatus_1.ResultStatus.pending: this.pending++; break; case resultStatus_1.ResultStatus.ambiguous: this.ambiguous++; break; case resultStatus_1.ResultStatus.skipped: this.skipped++; break; default: { // tslint:disable-next-line: max-line-length throw new Error(`Undefined result status for ${result.status}. Please raise a GitHub issue with the Yachr Team`); } } } } exports.ScenarioSummary = ScenarioSummary; //# sourceMappingURL=scenarioSummary.js.map