chore: remove defunct GlobalInfo.attach test (#13895)

This commit is contained in:
Ross Wollman 2022-05-03 06:18:16 -07:00 committed by GitHub
parent 4f5fbea26f
commit c15462d44c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -238,58 +238,6 @@ test(`testInfo.attach should save attachments via inline attachment`, async ({ r
}
});
test(`GlobalInfo.attach works`, async ({ runInlineTest }, testInfo) => {
const result = await runInlineTest({
'globalSetup.ts': `
import fs from 'fs';
import { FullConfig, GlobalInfo } from '@playwright/test';
async function globalSetup(config: FullConfig, globalInfo: GlobalInfo) {
const external = 'external.txt';
await fs.promises.writeFile(external, 'external');
await globalInfo.attach('inline.txt', { body: Buffer.from('inline'), contentType: 'text/plain' });
await globalInfo.attach('external.txt', { path: external, contentType: 'text/plain' });
// The attach call above should have saved it to a safe place
await fs.promises.unlink(external);
};
export default globalSetup;
`,
'playwright.config.ts': `
import path from 'path';
const config = {
globalSetup: path.join(__dirname, './globalSetup'),
}
export default config;
`,
'example.spec.ts': `
const { test } = pwt;
test('sample', async ({}) => { expect(2).toBe(2); });
`,
}, { reporter: 'dot,' + kRawReporterPath, workers: 1 }, {}, { usesCustomOutputDir: true });
expect(result.exitCode).toBe(0);
const outputPath = testInfo.outputPath('test-results', 'report', 'project.report');
const json = JSON.parse(fs.readFileSync(outputPath, 'utf-8'));
{
const attachment = json.attachments[0];
expect(attachment.name).toBe('inline.txt');
expect(attachment.contentType).toBe('text/plain');
expect(attachment.path).toBeUndefined();
expect(Buffer.from(attachment.body, 'base64').toString()).toEqual('inline');
}
{
const attachment = json.attachments[1];
expect(attachment.name).toBe('external.txt');
expect(attachment.contentType).toBe('text/plain');
const contents = fs.readFileSync(attachment.path);
expect(attachment.path.startsWith(path.join(testInfo.outputDir, 'attachments')), 'Attachment should be in our output directory.').toBeTruthy();
expect(contents.toString()).toEqual('external');
expect(attachment.body).toBeUndefined();
}
});
test('dupe project names', async ({ runInlineTest }, testInfo) => {
await runInlineTest({
'playwright.config.ts': `