Skip to content

Instantly share code, notes, and snippets.

@reboottime
Created June 11, 2024 00:18
Show Gist options
  • Save reboottime/4cb5ffa2fdf1ab9ee091e8d691a06460 to your computer and use it in GitHub Desktop.
Save reboottime/4cb5ffa2fdf1ab9ee091e8d691a06460 to your computer and use it in GitHub Desktop.
playwright test downloading file
test('Downloads report', async ({ page }) => {
const downloadPromise = page.waitForEvent('download');
await page.getByRole('button', { name: 'Download Report' }).click();
const download = await downloadPromise;
const expectedFileName = report.name + '.pdf';
expect(download.suggestedFilename()).toBe(expectedFileName);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment