Skip to content

Commit

Permalink
fix: bring back old attempt computing
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Sep 27, 2023
1 parent 5c20e72 commit be91742
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/test-adapter/cache/playwright.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const testsAttempts: Map<string, number> = new Map();
18 changes: 14 additions & 4 deletions lib/test-adapter/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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[] {
Expand Down Expand Up @@ -125,7 +135,7 @@ export class PlaywrightTestAdapter implements ReporterTestResult {
}

get attempt(): number {
return this._testResult.retry;
return this._attempt;
}

get browserId(): string {
Expand Down
2 changes: 1 addition & 1 deletion test/func/fixtures/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineConfig({
},
fullyParallel: true,
forbidOnly: true,
retries: 2,
repeatEach: 2,
workers: 1,
reporter: [
['html-reporter-tester/playwright', {
Expand Down

0 comments on commit be91742

Please sign in to comment.