playwright-bdd
Version:
BDD Testing with Playwright runner
43 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FinalRetryTestCase = void 0;
/**
* Builds the HTML-specific testCase envelope for the final non-retried attempt of a scenario.
* It reuses canonical TestCase step IDs but filters hook steps to only those executed in this run.
*/
class FinalRetryTestCase {
constructor(testCaseRun, testRunStartedId) {
this.testCaseRun = testCaseRun;
this.testCaseRun = testCaseRun;
this.testCase = testCaseRun.getTestCase();
const testSteps = [
...this.getRunHookSteps('before'),
...this.testCase.getSteps(),
...this.getRunHookSteps('after'),
];
this.testCaseId = this.testCase.id;
this.testCaseRunId = testCaseRun.id;
this.testStepIds = new Set(testSteps.map(({ id }) => id));
this.envelope = {
testCase: {
testRunStartedId,
id: this.testCase.id,
pickleId: this.testCase.pickle.id,
testSteps,
},
};
}
/**
* Returns hook test steps for the given hook type, filtered to only those that were actually
* executed in this run. Hooks accumulated on the shared TestCase may include hooks from
* previous retries that did not run in the final attempt (e.g. a BeforeAll that only ran once),
* so we intersect with the executed hooks of this specific TestCaseRun.
*/
getRunHookSteps(hookType) {
return Array.from(this.testCase.getHooks(hookType).entries())
.filter(([internalId]) => this.testCaseRun.getExecutedHooks(hookType).has(internalId))
.map(([, { testStep }]) => testStep);
}
}
exports.FinalRetryTestCase = FinalRetryTestCase;
//# sourceMappingURL=FinalRetryTestCase.js.map