UNPKG

playwright-fluent

Version:
52 lines (51 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const playwright_1 = require("playwright"); const __1 = require(".."); const SUT = tslib_1.__importStar(require("./index")); describe('show-mouse-position', () => { let browser = undefined; // eslint-disable-next-line @typescript-eslint/no-empty-function beforeEach(() => { }); afterEach(async () => { if (browser) { await browser.close(); } }); test('should return an error when page has not been initalized', async () => { // Given const page = undefined; // When // Then const expectedError = new Error('Cannot show mouse position because no browser has been launched'); await SUT.showMousePosition(page).catch((error) => expect(error).toMatchObject(expectedError)); }); test('should show cursor on the page on chromium', async () => { // Given const url = 'https://reactstrap.github.io/components/form'; browser = await playwright_1.chromium.launch({ headless: true }); const context = await browser.newContext({ viewport: null }); const page = await context.newPage(); // When await SUT.showMousePosition(page); await page.goto(url); // Then const cursorExists = await (0, __1.exists)('playwright-mouse-pointer', page); expect(cursorExists).toBe(true); }); test('should show cursor on navigating to another page on chromium', async () => { // Given const url = 'https://reactstrap.github.io/components/form'; browser = await playwright_1.chromium.launch({ headless: true }); const context = await browser.newContext({ viewport: null }); const page = await context.newPage(); // When await SUT.showMousePosition(page); await page.goto(url); await page.goto('https://google.com'); // Then const cursorExists = await (0, __1.exists)('playwright-mouse-pointer', page); expect(cursorExists).toBe(true); }); });