UNPKG

playwright-fluent

Version:
50 lines (49 loc) 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const playwright_fluent_1 = require("../../playwright-fluent"); describe('Playwright Fluent - withOptions', () => { let p; beforeEach(() => { p = new playwright_fluent_1.PlaywrightFluent(); }); afterEach(async () => { await p.close(); }); test('should target chromium in headfull mode', async () => { // Given const browser = 'chromium'; // When await p.withBrowser(browser).withOptions({ headless: false }); // Then const browserInstance = p.currentBrowser(); const pageInstance = p.currentPage(); expect(browserInstance).toBeDefined(); expect(pageInstance).toBeDefined(); const userAgent = pageInstance && (await pageInstance.evaluate(() => window.navigator.userAgent)); expect(userAgent).toContain('Chrome'); expect(userAgent).not.toContain('Headless'); }); test('should target chromium in headfull mode with custom window size', async () => { // Given const browser = 'chromium'; const options = { headless: false, args: ['--window-size=999,700'], }; const url = 'https://reactstrap.github.io'; // When // prettier-ignore await p .withBrowser(browser) .withOptions(options) .navigateTo(url); // Then const windowState = await p.getCurrentWindowState(); expect(Math.abs(windowState.outerWidth - 999)).toBeLessThanOrEqual(20); expect(Math.abs(windowState.outerHeight - 700)).toBeLessThanOrEqual(40); // Then default viewport should have (almost) the same size as the browser window const viewport = { width: windowState.innerWidth, height: windowState.innerHeight }; expect(Math.abs(viewport.height - windowState.outerHeight)).toBeLessThanOrEqual(132); expect(Math.abs(viewport.width - windowState.outerWidth)).toBeLessThanOrEqual(20); }); });