fix(test runner): dispatcher transformation of empty attachments (#11414)
This commit is contained in:
parent
59b677139e
commit
33f32368e5
|
|
@ -204,7 +204,7 @@ export class Dispatcher {
|
|||
name: a.name,
|
||||
path: a.path,
|
||||
contentType: a.contentType,
|
||||
body: a.body ? Buffer.from(a.body, 'base64') : undefined
|
||||
body: typeof a.body !== 'undefined' ? Buffer.from(a.body, 'base64') : undefined
|
||||
}));
|
||||
result.status = params.status;
|
||||
test.expectedStatus = params.expectedStatus;
|
||||
|
|
|
|||
|
|
@ -143,3 +143,33 @@ test(`testInfo.attach success in fixture`, async ({ runInlineTest }) => {
|
|||
expect(result.failed).toBe(1);
|
||||
expect(stripAscii(result.output)).toContain('attachment #1: name (text/plain)');
|
||||
});
|
||||
|
||||
test(`testInfo.attach allow empty string body`, async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = pwt;
|
||||
test('success', async ({}, testInfo) => {
|
||||
await testInfo.attach('name', { body: '', contentType: 'text/plain' });
|
||||
expect(0).toBe(1);
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.failed).toBe(1);
|
||||
expect(stripAscii(result.output)).toMatch(/^.*attachment #1: name \(text\/plain\).*\n.*\n.*------/gm);
|
||||
});
|
||||
|
||||
test(`testInfo.attach allow empty buffer body`, async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = pwt;
|
||||
test('success', async ({}, testInfo) => {
|
||||
await testInfo.attach('name', { body: Buffer.from(''), contentType: 'text/plain' });
|
||||
expect(0).toBe(1);
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.failed).toBe(1);
|
||||
expect(stripAscii(result.output)).toMatch(/^.*attachment #1: name \(text\/plain\).*\n.*\n.*------/gm);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue