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

This commit is contained in:
Mark 2024-10-08 01:14:46 +01:00 committed by GitHub
parent 7047c3a6c6
commit 04bf425268
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 2 deletions

View File

@ -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 {

View File

@ -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');
});
});
}
}