UNPKG

html-reporter

Version:

Html-reporter and GUI for viewing and managing results of a tests run. Currently supports Testplane and Hermione.

103 lines 3.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlaywrightTestAdapter = void 0; const playwright_1 = require("../test-result/playwright"); const constants_1 = require("../../constants"); class PlaywrightTestAdapter { static create(test) { return new this(test); } constructor(test) { this._test = test; } get original() { return this._test; } get id() { return this._test.title; } get pending() { return false; } get disabled() { return false; } get silentlySkipped() { return false; } get browserId() { return this._test.browserName; } get fullName() { return this._test.title; } get file() { return this._test.file; } get titlePath() { return this._test.titlePath; } createTestResult(opts) { const { status, attempt = constants_1.UNKNOWN_ATTEMPT, assertViewResults = [] } = opts; const testCase = { titlePath: () => ['', this._test.browserName, this._test.file, ...this._test.titlePath], title: this._test.title, annotations: [], location: { file: this._test.file }, parent: { project: () => ({ name: this._test.browserName }) } }; const attachments = assertViewResults.map(assertViewResult => { const attachmentByState = [generateExpectedAttachment(assertViewResult, assertViewResult.refImg)]; if (assertViewResult.currImg) { attachmentByState.push(generateActualAttachment(assertViewResult, assertViewResult.currImg)); } if (assertViewResult.diffImg) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion attachmentByState.push(generateDiffAttachment(assertViewResult, assertViewResult.diffImg)); } return attachmentByState; }).flat(); const result = { attachments, status, steps: [], startTime: new Date() }; return playwright_1.PlaywrightTestResultAdapter.create(testCase, result, attempt); } } exports.PlaywrightTestAdapter = PlaywrightTestAdapter; function generateExpectedAttachment(assertViewResult, imageFile) { return { name: `${assertViewResult.stateName}${playwright_1.ImageTitleEnding.Expected}`, relativePath: assertViewResult.refImg.relativePath, ...generateAttachment(assertViewResult, imageFile) }; } function generateActualAttachment(assertViewResult, imageFile) { return { name: `${assertViewResult.stateName}${playwright_1.ImageTitleEnding.Actual}`, ...generateAttachment(assertViewResult, imageFile) }; } function generateDiffAttachment(assertViewResult, imageFile) { return { name: `${assertViewResult.stateName}${playwright_1.ImageTitleEnding.Diff}`, ...generateAttachment(assertViewResult, imageFile) }; } function generateAttachment(assertViewResult, imageFile) { return { path: imageFile.path, contentType: 'image/png', size: imageFile.size, isUpdated: assertViewResult.isUpdated }; } //# sourceMappingURL=playwright.js.map