playwright-fluent
Version:
Fluent API around playwright
36 lines (35 loc) • 1.69 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
const playwright_1 = require("playwright");
const SUT = tslib_1.__importStar(require("../index"));
const utils_1 = require("../../../../utils");
describe('record downloads to', () => {
let browser = undefined;
// eslint-disable-next-line @typescript-eslint/no-empty-function
beforeEach(() => { });
afterEach(async () => {
if (browser) {
await browser.close();
}
});
test('should record successfull downloads', async () => {
// Given
browser = await playwright_1.chromium.launch({ headless: false });
const context = await browser.newContext({ viewport: null, acceptDownloads: true });
const page = await context.newPage();
const downloadsDirectory = path.join(__dirname, 'downloads');
await (0, utils_1.ensureDirectoryExists)(downloadsDirectory);
const expectedDownloadedFilepath = path.join(downloadsDirectory, 'download.zip');
(0, utils_1.deleteFile)(expectedDownloadedFilepath);
// When
await SUT.recordDownloadsTo(downloadsDirectory, page);
await page.goto(`file:${path.join(__dirname, 'record-downloads-to.test.html')}`);
await page.click('a#download-package');
// Then
// eslint-disable-next-line no-console
console.log(`user home directory : '${utils_1.userHomeDirectory}'`);
await (0, utils_1.waitUntil)(async () => (0, utils_1.fileExists)(expectedDownloadedFilepath), `File '${expectedDownloadedFilepath}' is not downloaded`);
});
});
;