playwright-fluent
Version:
Fluent API around playwright
58 lines (57 loc) • 2.02 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const playwright_fluent_1 = require("../../playwright-fluent");
const devices_1 = require("../../../devices");
describe('Playwright Fluent - withViewPort', () => {
let p;
beforeEach(() => {
p = new playwright_fluent_1.PlaywrightFluent();
});
afterEach(async () => {
await p.close();
});
test('should target firefox in headfull mode with viewport size 800x600', async () => {
// Given
const browser = 'firefox';
const options = {
headless: false,
};
const url = 'https://reactstrap.github.io';
const viewport = {
...devices_1.sizeOf._800x600,
};
// When
// prettier-ignore
await p
.withBrowser(browser)
.withOptions(options)
.withViewport(viewport)
.navigateTo(url);
// Then
const windowState = await p.getCurrentWindowState();
expect(Math.abs(windowState.innerWidth - viewport.width)).toBeLessThanOrEqual(10);
expect(Math.abs(windowState.innerHeight - viewport.height)).toBeLessThanOrEqual(10);
});
test('should target firefox in headfull mode with viewport size 1920x1440', async () => {
// Given
const browser = 'firefox';
const options = {
headless: false,
};
const url = 'https://reactstrap.github.io';
const viewport = {
...devices_1.sizeOf._1920x1440,
};
// When
// prettier-ignore
await p
.withBrowser(browser)
.withOptions(options)
.withViewport(viewport)
.navigateTo(url);
// Then
const windowState = await p.getCurrentWindowState();
expect(Math.abs(windowState.innerWidth - viewport.width)).toBeLessThanOrEqual(10);
expect(Math.abs(windowState.innerHeight - viewport.height)).toBeLessThanOrEqual(10);
});
});
;