UNPKG

playwright-fluent

Version:
71 lines (70 loc) 3.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path = tslib_1.__importStar(require("path")); const playwright_1 = require("playwright"); const playwright_fluent_1 = require("../../playwright-fluent"); describe('Playwright Fluent - ctor usage', () => { // eslint-disable-next-line @typescript-eslint/no-empty-function beforeEach(() => { }); test('should take existing browser and page instance of chromium', async () => { // Given const browser = await playwright_1.chromium.launch({ headless: true }); const context = await browser.newContext(); const url = `file:${path.join(__dirname, 'ctor.test.html')}`; const page = await context.newPage(); await page.goto(url); // When const p = new playwright_fluent_1.PlaywrightFluent(browser, page); // Then expect(p.currentBrowser()).toBe(browser); expect(p.currentPage()).toBe(page); expect(p.currentFrame()).toBeUndefined(); await browser.close(); }); test('should take existing browser and page instance of firefox', async () => { // Given const browser = await playwright_1.firefox.launch({ headless: true }); const context = await browser.newContext(); // const url = `file:${path.join(__dirname, 'ctor.test.html')}`; const page = await context.newPage(); await page.goto('https://google.com'); // When const p = new playwright_fluent_1.PlaywrightFluent(browser, page); // Then expect(p.currentBrowser()).toBe(browser); expect(p.currentPage()).toBe(page); expect(p.currentFrame()).toBeUndefined(); await browser.close(); }); test('should take existing browser and page instance of webkit', async () => { // Given const browser = await playwright_1.webkit.launch({ headless: true }); const context = await browser.newContext(); const url = `file:${path.join(__dirname, 'ctor.test.html')}`; const page = await context.newPage(); await page.goto(url); // When const p = new playwright_fluent_1.PlaywrightFluent(browser, page); // Then expect(p.currentBrowser()).toBe(browser); expect(p.currentPage()).toBe(page); expect(p.currentFrame()).toBeUndefined(); await browser.close(); }); test.skip('should take existing browser and page instance of firefox', async () => { // Given const browser = await playwright_1.firefox.launch({ headless: true }); const context = await browser.newContext(); const url = `file:${path.join(__dirname, 'ctor.test.html')}`; const page = await context.newPage(); await page.goto(url); // When const p = new playwright_fluent_1.PlaywrightFluent(browser, page); // Then expect(p.currentBrowser()).toBe(browser); expect(p.currentPage()).toBe(page); expect(p.currentFrame()).toBeUndefined(); await browser.close(); }); });