test(downloads): add passing test for downloads and interception (#6586)

This commit is contained in:
Joel Einbinder 2021-05-14 13:28:42 -07:00 committed by GitHub
parent 37d03e8b7b
commit 7bbb91f265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -469,4 +469,19 @@ it.describe('download event', () => {
expect(data.equals(content)).toBe(true); expect(data.equals(content)).toBe(true);
await page.close(); await page.close();
}); });
it('should report downloads with interception', async ({browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
await page.route(/.*/, r => r.continue());
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const path = await download.path();
expect(fs.existsSync(path)).toBeTruthy();
expect(fs.readFileSync(path).toString()).toBe('Hello world');
await page.close();
});
}); });