Skip to content

Commit 78bf821

Browse files
committed
feat(html): show repeatEachIndex when non-zero
This helps to differentiate between attempts.
1 parent 3f40d6e commit 78bf821

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

packages/html-reporter/src/testCaseView.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const TestCaseView: React.FC<{
4343
const searchParams = useSearchParams();
4444

4545
const visibleTestAnnotations = test.annotations.filter(a => !a.type.startsWith('_')) ?? [];
46+
appendRepeatEachIndexAnnotation(visibleTestAnnotations, test.repeatEachIndex);
4647

4748
return <>
4849
<HeaderView
@@ -78,6 +79,7 @@ export const TestCaseView: React.FC<{
7879
</div>,
7980
render: () => {
8081
const visibleAnnotations = result.annotations.filter(annotation => !annotation.type.startsWith('_'));
82+
appendRepeatEachIndexAnnotation(visibleAnnotations, test.repeatEachIndex);
8183
return <>
8284
{!!visibleAnnotations.length && <AutoChip header='Annotations' dataTestId='test-case-annotations'>
8385
{visibleAnnotations.map((annotation, index) => <TestCaseAnnotationView key={index} annotation={annotation} />)}
@@ -98,6 +100,11 @@ function TestCaseAnnotationView({ annotation: { type, description } }: { annotat
98100
);
99101
}
100102

103+
function appendRepeatEachIndexAnnotation(annotations: TestAnnotation[], repeatEachIndex: number | undefined) {
104+
if (repeatEachIndex)
105+
annotations.push({ type: 'repeatEachIndex', description: String(repeatEachIndex) });
106+
}
107+
101108
function retryLabel(index: number) {
102109
if (!index)
103110
return 'Run';

packages/html-reporter/src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export type TestCaseSummary = {
8484
duration: number;
8585
ok: boolean;
8686
results: TestResultSummary[];
87+
repeatEachIndex?: number;
8788
};
8889

8990
export type TestResultSummary = {

packages/playwright/src/reporters/html.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ class HtmlBuilder {
451451
outcome: test.outcome(),
452452
path,
453453
results,
454+
repeatEachIndex: test.repeatEachIndex || undefined, // Do not include zero.
454455
ok: test.outcome() === 'expected' || test.outcome() === 'flaky',
455456
},
456457
testCaseSummary: {
@@ -464,6 +465,7 @@ class HtmlBuilder {
464465
outcome: test.outcome(),
465466
path,
466467
ok: test.outcome() === 'expected' || test.outcome() === 'flaky',
468+
repeatEachIndex: test.repeatEachIndex || undefined, // Do not include zero.
467469
results: results.map(result => {
468470
return {
469471
attachments: result.attachments.map(a => ({ name: a.name, contentType: a.contentType, path: a.path })),

0 commit comments

Comments
 (0)