playwright-fluent
Version:
Fluent API around playwright
35 lines (34 loc) • 1.4 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
const SUT = tslib_1.__importStar(require("../../playwright-fluent"));
const utils_1 = require("../../../utils");
describe('Playwright Fluent - recordDownloadsTo(directory)', () => {
let p;
beforeEach(() => {
p = new SUT.PlaywrightFluent();
});
afterEach(async () => {
await p.close();
});
test('should record successfull downloads', async () => {
// Given
const url = `file:${path.join(__dirname, 'record-downloads-to.test.html')}`;
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 p
.withBrowser('chromium')
.withOptions({ headless: true })
.withCursor()
.recordDownloadsTo(downloadsDirectory)
.navigateTo(url)
.click('a#download-package')
.waitUntil(async () => (0, utils_1.fileExists)(expectedDownloadedFilepath));
// Then
expect((0, utils_1.fileExists)(expectedDownloadedFilepath)).toBe(true);
});
});
;