chore: process stdio buffers (#22270)
Fixes https://github.com/microsoft/playwright/issues/22265
This commit is contained in:
parent
d59e0e10ce
commit
eed5b4c83b
|
|
@ -263,7 +263,7 @@ export class TeleReporterReceiver {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onStdIO(type: 'stdout' | 'stderr', testId: string | undefined, resultId: string | undefined, data: string, isBase64: boolean) {
|
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 test = testId ? this._tests.get(testId) : undefined;
|
||||||
const result = test && resultId ? test.resultsMap.get(resultId) : undefined;
|
const result = test && resultId ? test.resultsMap.get(resultId) : undefined;
|
||||||
if (type === 'stdout')
|
if (type === 'stdout')
|
||||||
|
|
|
||||||
|
|
@ -56,3 +56,21 @@ test('should work after theme switch', async ({ runUITest, writeFiles }) => {
|
||||||
await page.getByTitle('Run all').click();
|
await page.getByTitle('Run all').click();
|
||||||
await expect(page.getByTestId('output')).toContainText(`Hello world 2`);
|
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 });
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue