Skip to content

Commit

Permalink
chore: trim multiline step titles to first line (#31269)
Browse files Browse the repository at this point in the history
Fixes #31266
  • Loading branch information
yury-s committed Jun 12, 2024
1 parent 6a7bfe6 commit f1475fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/playwright/src/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ function relativeTestPath(config: FullConfig, test: TestCase): string {

export function stepSuffix(step: TestStep | undefined) {
const stepTitles = step ? step.titlePath() : [];
return stepTitles.map(t => ' › ' + t).join('');
return stepTitles.map(t => t.split('\n')[0]).map(t => ' › ' + t).join('');
}

export function formatTestTitle(config: FullConfig, test: TestCase, step?: TestStep, omitLocation: boolean = false): string {
Expand Down
22 changes: 22 additions & 0 deletions tests/playwright-test/reporter-line.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ for (const useIntermediateMergeReport of [false, true] as const) {
].join('\n'));
});

test('should trim multiline step titles to first line', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/31266' }
}, async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('passes', async ({}) => {
await test.step(\`outer
1.0\`, async () => {
await test.step(\`inner
1.1\`, async () => {
expect(1).toBe(1);
});
});
});
`,
}, { reporter: 'line' });
const text = result.output;
expect(text).toContain('[1/1] a.test.ts:6:26 › passes › outer › inner');
expect(result.exitCode).toBe(0);
});

test('should render failed test steps', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.ts': `
Expand Down

0 comments on commit f1475fa

Please sign in to comment.