|
16 | 16 |
|
17 | 17 | import { playwrightTest as it, expect } from './config/browserTest';
|
18 | 18 | import fs from 'fs';
|
| 19 | +import path from 'path'; |
19 | 20 |
|
20 | 21 | it.describe('downloads path', () => {
|
21 | 22 | it.beforeEach(async ({server}) => {
|
@@ -71,6 +72,20 @@ it.describe('downloads path', () => {
|
71 | 72 | await downloadsBrowser.close();
|
72 | 73 | });
|
73 | 74 |
|
| 75 | + it('should report downloads in downloadsPath folder with a relative path', async ({browserType, browserOptions, server}, testInfo) => { |
| 76 | + const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: path.relative(process.cwd(), testInfo.outputPath('')) }); |
| 77 | + const page = await downloadsBrowser.newPage({ acceptDownloads: true }); |
| 78 | + await page.setContent(`<a href="${server.PREFIX}/download">download</a>`); |
| 79 | + const [ download ] = await Promise.all([ |
| 80 | + page.waitForEvent('download'), |
| 81 | + page.click('a') |
| 82 | + ]); |
| 83 | + const downloadPath = await download.path(); |
| 84 | + expect(downloadPath.startsWith(testInfo.outputPath(''))).toBeTruthy(); |
| 85 | + await page.close(); |
| 86 | + await downloadsBrowser.close(); |
| 87 | + }); |
| 88 | + |
74 | 89 | it('should accept downloads in persistent context', async ({launchPersistent, server}, testInfo) => {
|
75 | 90 | const { context, page } = await launchPersistent({ acceptDownloads: true, downloadsPath: testInfo.outputPath('') });
|
76 | 91 | await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
|
0 commit comments