Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(reporter): line reporter should not swallow half-line stdout (#15114)

Dmitry Gozmana93db3cf11ac
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'));
+});