Skip to content

Commit

Permalink
feat(base-reporter): Add tags to test output (#32930)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkstwrt authored Oct 8, 2024
1 parent 7047c3a commit 04bf425
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/playwright/src/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 15 additions & 1 deletion tests/playwright-test/reporter-base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
}
}

0 comments on commit 04bf425

Please sign in to comment.