chore: process stdio buffers (#22270)

Fixes https://github.com/microsoft/playwright/issues/22265
This commit is contained in:
Pavel Feldman 2023-04-07 13:50:15 -07:00 committed by GitHub
parent d59e0e10ce
commit eed5b4c83b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -263,7 +263,7 @@ export class TeleReporterReceiver {
}
private _onStdIO(type: 'stdout' | 'stderr', testId: string | undefined, resultId: string | undefined, data: string, isBase64: boolean) {
const chunk = isBase64 ? Buffer.from(data, 'base64') : data;
const chunk = isBase64 ? ((globalThis as any).Buffer ? Buffer.from(data, 'base64') : atob(data)) : data;
const test = testId ? this._tests.get(testId) : undefined;
const result = test && resultId ? test.resultsMap.get(resultId) : undefined;
if (type === 'stdout')

View file

@ -56,3 +56,21 @@ test('should work after theme switch', async ({ runUITest, writeFiles }) => {
await page.getByTitle('Run all').click();
await expect(page.getByTestId('output')).toContainText(`Hello world 2`);
});
test('should print buffers', async ({ runUITest }) => {
const { page } = await runUITest({
'a.test.ts': `
import { test } from '@playwright/test';
import { PassThrough } from 'stream';
test('print', () => {
const writable = new PassThrough();
writable.pipe(process.stdout);
const red = Buffer.from('G1szMW1IRUxMTxtbMzlt', 'base64');
writable.write(red);
});
`,
});
await page.getByTitle('Toggle output').click();
await page.getByTitle('Run all').click();
await expect(page.getByTestId('output')).toContainText('HELLO', { timeout: 15000 });
});