UNPKG

@serenity-js/playwright-test

Version:

Serenity/JS test runner adapter for Playwright Test, combining Playwright's developer experience with the advanced reporting and automation capabilities of Serenity/JS

44 lines 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PerformActivitiesAsPlaywrightSteps = void 0; const core_1 = require("@serenity-js/core"); const objects_1 = require("tiny-types/lib/objects"); class PerformActivitiesAsPlaywrightSteps extends core_1.PerformActivities { test; constructor(actor, stage, test) { super(actor, stage); this.test = test; } async perform(activity) { const testInfo = this.test.info(); // Monkey-patch addStep to allow for passing a pre-computed location // see https://github.com/microsoft/playwright/issues/30160 const originalAddStep = testInfo._addStep; testInfo._addStep = (data) => { data.location = this.locationOf(activity); data.params = this.parametersOf(activity); return originalAddStep.call(testInfo, data); }; await this.test.step(await activity.describedBy(this.actor), () => super.perform(activity)); testInfo._addStep = originalAddStep; } parametersOf(activity) { if (activity instanceof core_1.Interaction) { return (0, objects_1.significantFieldsOf)(activity).reduce((acc, field) => { acc[field] = (0, core_1.d) `${activity[field]}`; return acc; }, {}); } return {}; } locationOf(activity) { const instantiationLocation = activity.instantiationLocation(); return { file: instantiationLocation.path.value, line: instantiationLocation.line, column: instantiationLocation.column }; } } exports.PerformActivitiesAsPlaywrightSteps = PerformActivitiesAsPlaywrightSteps; //# sourceMappingURL=PerformActivitiesAsPlaywrightSteps.js.map