From a93db3cf11acba391bdf14fdd04c7975424d7d39 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Mon, 27 Jun 2022 11:25:42 -0700 Subject: [PATCH] fix(reporter): line reporter should not swallow half-line stdout (#15114) --- .../playwright-test/src/reporters/line.ts | 3 +++ tests/playwright-test/reporter-line.spec.ts | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/playwright-test/src/reporters/line.ts b/packages/playwright-test/src/reporters/line.ts index ebb02ce9a5..017cd89e9e 100644 --- a/packages/playwright-test/src/reporters/line.ts +++ b/packages/playwright-test/src/reporters/line.ts @@ -56,6 +56,9 @@ class LineReporter extends BaseReporter { } stream.write(chunk); + if (chunk[chunk.length - 1] !== '\n') + console.log(); + console.log(); } diff --git a/tests/playwright-test/reporter-line.spec.ts b/tests/playwright-test/reporter-line.spec.ts index 982185cb84..56ba9efc96 100644 --- a/tests/playwright-test/reporter-line.spec.ts +++ b/tests/playwright-test/reporter-line.spec.ts @@ -82,3 +82,25 @@ test('should work on CI', async ({ runInlineTest }) => { expect(text).toContain('1) a.test'); expect(result.exitCode).toBe(1); }); + +test('should print output', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.spec.ts': ` + const { test } = pwt; + test('foobar', async ({}, testInfo) => { + process.stdout.write('one'); + process.stdout.write('two'); + console.log('full-line'); + }); + ` + }, { reporter: 'line' }); + expect(result.exitCode).toBe(0); + expect(stripAnsi(result.output)).toContain([ + 'a.spec.ts:6:7 › foobar', + 'one', + '', + 'two', + '', + 'full-line', + ].join('\n')); +});