Skip to content

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

feat(base-reporter): Add tags to test output (#32930)

Mark04bf425268fb
diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts
index 6776ce606f..4249429a36 100644
--- a/packages/playwright/src/reporters/base.ts
+++ b/packages/playwright/src/reporters/base.ts
@@ -410,7 +410,8 @@ export function formatTestTitle(config: FullConfig, test: TestCase, step?: TestS
else
location = `${relativeTestPath(config, test)}:${step?.location?.line ?? test.location.line}:${step?.location?.column ?? test.location.column}`;
const projectTitle = projectName ? `[${projectName}] › ` : '';
- return `${projectTitle}${location} › ${titles.join(' › ')}${stepSuffix(step)}`;
+ const tags = test.tags.length > 0 ? ` ${test.tags.join(' ')}` : '';
+ return `${projectTitle}${location} › ${titles.join(' › ')}${stepSuffix(step)}${tags}`;
}
function formatTestHeader(config: FullConfig, test: TestCase, options: { indent?: string, index?: number, mode?: 'default' | 'error' } = {}): string {
diff --git a/tests/playwright-test/reporter-base.spec.ts b/tests/playwright-test/reporter-base.spec.ts
index 6d6e499605..85ba731bf5 100644
--- a/tests/playwright-test/reporter-base.spec.ts
+++ b/tests/playwright-test/reporter-base.spec.ts
@@ -418,5 +418,19 @@ for (const useIntermediateMergeReport of [false, true] as const) {
expect(result.passed).toBe(1);
expect(result.output).toMatch(/\d+ passed \(\d+(\.\d)?(ms|s)\)/);
});
+
+ test('should output tags', async ({ runInlineTest }) => {
+ const result = await runInlineTest({
+ 'a.test.ts': `
+ const { test, expect } = require('@playwright/test');
+ test('passes', { tag: ['@foo', '@bar'] }, async ({}) => {
+ expect(0).toBe(0);
+ });
+ `,
+ });
+ const text = result.output;
+
+ expect(text).toContain('passes @foo @bar');
+ });
});
-}
\ No newline at end of file
+}