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

This commit is contained in:
Dmitry Gozman 2022-06-27 11:25:42 -07:00 committed by GitHub
parent d152f7957a
commit a93db3cf11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View file

@ -56,6 +56,9 @@ class LineReporter extends BaseReporter {
}
stream.write(chunk);
if (chunk[chunk.length - 1] !== '\n')
console.log();
console.log();
}

View file

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