mirror of
https://github.com/microsoft/playwright.git
synced 2024-10-27 21:58:52 +03:00
fix(reporter): properly indent multiline attachments (#20847)
Text attachments were only indented on the first line.
This commit is contained in:
parent
e9ca483666
commit
997dfa9274
@ -285,7 +285,8 @@ export function formatFailure(config: FullConfig, test: TestCase, options: {inde
|
||||
let text = attachment.body.toString();
|
||||
if (text.length > 300)
|
||||
text = text.slice(0, 300) + '...';
|
||||
resultLines.push(colors.cyan(` ${text}`));
|
||||
for (const line of text.split('\n'))
|
||||
resultLines.push(colors.cyan(` ${line}`));
|
||||
}
|
||||
}
|
||||
resultLines.push(colors.cyan(separator(' ')));
|
||||
|
@ -278,3 +278,26 @@ test(`testInfo.attach throw if name is not string`, async ({ runInlineTest }) =>
|
||||
|
||||
expect(result.output).toContain('"name" should be string.');
|
||||
});
|
||||
|
||||
test('render text attachment with multiple lines', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = pwt;
|
||||
test('one', async ({}, testInfo) => {
|
||||
testInfo.attachments.push({
|
||||
name: 'attachment',
|
||||
body: Buffer.from('First line\\nSecond line\\nThird line'),
|
||||
contentType: 'text/plain'
|
||||
});
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
`,
|
||||
}, { reporter: 'line' });
|
||||
const text = result.output;
|
||||
expect(text).toContain(' attachment #1: attachment (text/plain) ─────────────────────────────────────────────────────────');
|
||||
expect(text).toContain(' First line');
|
||||
expect(text).toContain(' Second line');
|
||||
expect(text).toContain(' Third line');
|
||||
expect(text).toContain(' ────────────────────────────────────────────────────────────────────────────────────────────────');
|
||||
expect(result.exitCode).toBe(1);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user