Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(list reporter): do not print step location instead of test location (#34022)

Dmitry Gozmanaa1fe61cc951
diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts
index 9317e4e1bc..7a081e9f85 100644
--- a/packages/playwright/src/reporters/base.ts
+++ b/packages/playwright/src/reporters/base.ts
@@ -381,7 +381,7 @@ export function formatTestTitle(config: FullConfig, test: TestCase, step?: TestS
if (omitLocation)
location = `${relativeTestPath(config, test)}`;
else
- location = `${relativeTestPath(config, test)}:${step?.location?.line ?? test.location.line}:${step?.location?.column ?? test.location.column}`;
+ location = `${relativeTestPath(config, test)}:${test.location.line}:${test.location.column}`;
const projectTitle = projectName ? `[${projectName}] › ` : '';
const testTitle = `${projectTitle}${location} › ${titles.join(' › ')}`;
const extraTags = test.tags.filter(t => !testTitle.includes(t));
diff --git a/tests/playwright-test/reporter-line.spec.ts b/tests/playwright-test/reporter-line.spec.ts
index 14959877b5..22441d567a 100644
--- a/tests/playwright-test/reporter-line.spec.ts
+++ b/tests/playwright-test/reporter-line.spec.ts
@@ -127,7 +127,7 @@ for (const useIntermediateMergeReport of [false, true] as const) {
`,
}, { reporter: 'line' });
const text = result.output;
- expect(text).toContain('[1/1] a.test.ts:6:26 › passes › outer › inner');
+ expect(text).toContain('[1/1] a.test.ts:3:15 › passes › outer › inner');
expect(result.exitCode).toBe(0);
});
diff --git a/tests/playwright-test/reporter-list.spec.ts b/tests/playwright-test/reporter-list.spec.ts
index c57190a5d7..752d29c649 100644
--- a/tests/playwright-test/reporter-list.spec.ts
+++ b/tests/playwright-test/reporter-list.spec.ts
@@ -111,17 +111,17 @@ for (const useIntermediateMergeReport of [false, true] as const) {
lines.pop(); // Remove last item that contains [v] and time in ms.
expect(lines).toEqual([
'#0 : 1 a.test.ts:3:11 › passes',
- '#0 : 1 a.test.ts:4:20 › passes › outer 1.0',
- '#0 : 1 a.test.ts:5:22 › passes › outer 1.0 › inner 1.1',
- '#0 : 1 a.test.ts:4:20 › passes › outer 1.0',
- '#0 : 1 a.test.ts:6:22 › passes › outer 1.0 › inner 1.2',
- '#0 : 1 a.test.ts:4:20 › passes › outer 1.0',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 1.0',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 1.0 › inner 1.1',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 1.0',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 1.0 › inner 1.2',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 1.0',
'#0 : 1 a.test.ts:3:11 › passes',
- '#0 : 1 a.test.ts:8:20 › passes › outer 2.0',
- '#0 : 1 a.test.ts:9:22 › passes › outer 2.0 › inner 2.1',
- '#0 : 1 a.test.ts:8:20 › passes › outer 2.0',
- '#0 : 1 a.test.ts:10:22 › passes › outer 2.0 › inner 2.2',
- '#0 : 1 a.test.ts:8:20 › passes › outer 2.0',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 2.0',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 2.0 › inner 2.1',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 2.0',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 2.0 › inner 2.2',
+ '#0 : 1 a.test.ts:3:11 › passes › outer 2.0',
'#0 : 1 a.test.ts:3:11 › passes',
]);
});
@@ -145,12 +145,12 @@ for (const useIntermediateMergeReport of [false, true] as const) {
const text = result.output;
const lines = text.split('\n').filter(l => l.match(/^#.* :/)).map(l => l.replace(/[.\d]+m?s/, 'Xms'));
expect(lines).toEqual([
- '#0 : 1.1 a.test.ts:5:26 › passes › outer 1.0 › inner 1.1 (Xms)',
- '#1 : 1.2 a.test.ts:6:26 › passes › outer 1.0 › inner 1.2 (Xms)',
- '#2 : 1.3 a.test.ts:4:24 › passes › outer 1.0 (Xms)',
- '#3 : 1.4 a.test.ts:9:26 › passes › outer 2.0 › inner 2.1 (Xms)',
- '#4 : 1.5 a.test.ts:10:26 › passes › outer 2.0 › inner 2.2 (Xms)',
- '#5 : 1.6 a.test.ts:8:24 › passes › outer 2.0 (Xms)',
+ '#0 : 1.1 a.test.ts:3:15 › passes › outer 1.0 › inner 1.1 (Xms)',
+ '#1 : 1.2 a.test.ts:3:15 › passes › outer 1.0 › inner 1.2 (Xms)',
+ '#2 : 1.3 a.test.ts:3:15 › passes › outer 1.0 (Xms)',
+ '#3 : 1.4 a.test.ts:3:15 › passes › outer 2.0 › inner 2.1 (Xms)',
+ '#4 : 1.5 a.test.ts:3:15 › passes › outer 2.0 › inner 2.2 (Xms)',
+ '#5 : 1.6 a.test.ts:3:15 › passes › outer 2.0 (Xms)',
`#6 : ${POSITIVE_STATUS_MARK} 1 a.test.ts:3:15 › passes (Xms)`,
]);
});