fix(html): encode all stdio attachments (#33950)
This commit is contained in:
parent
b0cec5b351
commit
dd36de7809
|
@ -602,17 +602,10 @@ type JsonAttachment = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function stdioAttachment(chunk: Buffer | string, type: 'stdout' | 'stderr'): JsonAttachment {
|
function stdioAttachment(chunk: Buffer | string, type: 'stdout' | 'stderr'): JsonAttachment {
|
||||||
if (typeof chunk === 'string') {
|
|
||||||
return {
|
return {
|
||||||
name: type,
|
name: type,
|
||||||
contentType: 'text/plain',
|
contentType: 'text/plain',
|
||||||
body: chunk
|
body: typeof chunk === 'string' ? chunk : chunk.toString('utf-8')
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
name: type,
|
|
||||||
contentType: 'application/octet-stream',
|
|
||||||
body: chunk
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2562,6 +2562,24 @@ for (const useIntermediateMergeReport of [true, false] as const) {
|
||||||
- button "tests/b/test.spec.ts"
|
- button "tests/b/test.spec.ts"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('execSync doesnt produce a second stdout attachment', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33886' } }, async ({ runInlineTest, showReport, page }) => {
|
||||||
|
await runInlineTest({
|
||||||
|
'a.test.js': `
|
||||||
|
const { test, expect } = require('@playwright/test');
|
||||||
|
const { execSync } = require('node:child_process');
|
||||||
|
test('my test', async ({}) => {
|
||||||
|
console.log('foo');
|
||||||
|
execSync('echo bar', { stdio: 'inherit' });
|
||||||
|
console.log('baz');
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { reporter: 'dot,html' });
|
||||||
|
|
||||||
|
await showReport();
|
||||||
|
await page.getByText('my test').click();
|
||||||
|
await expect(page.locator('.tree-item', { hasText: 'stdout' })).toHaveCount(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue