Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test(downloads): add passing test for downloads and interception (#6586)
Joel Einbinder7bbb91f26554
diff --git a/tests/download.spec.ts b/tests/download.spec.tsindex 94d6a504f6..77231fee00 100644--- a/tests/download.spec.ts+++ b/tests/download.spec.ts@@ -469,4 +469,19 @@ it.describe('download event', () => {expect(data.equals(content)).toBe(true);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();+ });+});