From be9174251a464905a6591cef224384df20012852 Mon Sep 17 00:00:00 2001 From: shadowusr Date: Thu, 28 Sep 2023 01:57:13 +0300 Subject: [PATCH] fix: bring back old attempt computing --- lib/test-adapter/cache/playwright.ts | 1 + lib/test-adapter/playwright.ts | 18 ++++++++++++++---- .../fixtures/playwright/playwright.config.ts | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 lib/test-adapter/cache/playwright.ts diff --git a/lib/test-adapter/cache/playwright.ts b/lib/test-adapter/cache/playwright.ts new file mode 100644 index 000000000..d040676b2 --- /dev/null +++ b/lib/test-adapter/cache/playwright.ts @@ -0,0 +1 @@ +export const testsAttempts: Map = new Map(); diff --git a/lib/test-adapter/playwright.ts b/lib/test-adapter/playwright.ts index cf3210c93..2e932b081 100644 --- a/lib/test-adapter/playwright.ts +++ b/lib/test-adapter/playwright.ts @@ -5,11 +5,13 @@ import _ from 'lodash'; import stripAnsi from 'strip-ansi'; import {ReporterTestResult} from './index'; +import {testsAttempts} from './cache/playwright'; +import {getShortMD5, isImageDiffError, isNoRefImageError, mkTestId} from '../common-utils'; import {FAIL, PWT_TITLE_DELIMITER, TestStatus} from '../constants'; -import {AssertViewResult, ErrorDetails, ImageData, ImageInfoFull, ImageSize, TestError} from '../types'; -import {getShortMD5, isImageDiffError, isNoRefImageError} from '../common-utils'; -import {ImagesInfoFormatter} from '../image-handler'; import {ErrorName} from '../errors'; +import {ImagesInfoFormatter} from '../image-handler'; +import {AssertViewResult, ErrorDetails, ImageData, ImageInfoFull, ImageSize, TestError} from '../types'; +import * as utils from '../server-utils'; export type PlaywrightAttachment = PlaywrightTestResult['attachments'][number]; @@ -88,12 +90,20 @@ export interface PlaywrightTestAdapterOptions { export class PlaywrightTestAdapter implements ReporterTestResult { private readonly _testCase: PlaywrightTestCase; private readonly _testResult: PlaywrightTestResult; + private _attempt: number; private _imagesInfoFormatter: ImagesInfoFormatter; constructor(testCase: PlaywrightTestCase, testResult: PlaywrightTestResult, {imagesInfoFormatter}: PlaywrightTestAdapterOptions) { this._testCase = testCase; this._testResult = testResult; this._imagesInfoFormatter = imagesInfoFormatter; + + const testId = mkTestId(this.fullName, this.browserId); + if (utils.shouldUpdateAttempt(this.status)) { + testsAttempts.set(testId, _.isUndefined(testsAttempts.get(testId)) ? 0 : testsAttempts.get(testId) as number + 1); + } + + this._attempt = testsAttempts.get(testId) || 0; } get assertViewResults(): AssertViewResult[] { @@ -125,7 +135,7 @@ export class PlaywrightTestAdapter implements ReporterTestResult { } get attempt(): number { - return this._testResult.retry; + return this._attempt; } get browserId(): string { diff --git a/test/func/fixtures/playwright/playwright.config.ts b/test/func/fixtures/playwright/playwright.config.ts index d7657d5ce..874872446 100644 --- a/test/func/fixtures/playwright/playwright.config.ts +++ b/test/func/fixtures/playwright/playwright.config.ts @@ -13,7 +13,7 @@ export default defineConfig({ }, fullyParallel: true, forbidOnly: true, - retries: 2, + repeatEach: 2, workers: 1, reporter: [ ['html-reporter-tester/playwright', {