UNPKG

playwright-fluent

Version:
78 lines (77 loc) 3.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); const playwright_fluent_1 = require("../../playwright-fluent"); const utils_1 = require("../../../utils"); describe('Playwright Fluent - withTracing()', () => { let p; beforeEach(() => { p = new playwright_fluent_1.PlaywrightFluent(); }); afterEach(async () => { await p.close(); }); test('should trace with chromium in headfull mode', async () => { // Given const browser = 'chromium'; const url = 'https://reactstrap.github.io'; const tracePath = path_1.default.join(__dirname, 'trace1.chromium.zip'); expect((0, utils_1.fileExists)(tracePath)).toBe(false); // When await p .withBrowser(browser) .withOptions({ headless: false }) .withTracing() .startTracing({ title: 'my first trace' }) .navigateTo(url) .stopTracingAndSaveTrace({ path: tracePath }) .waitUntil(async () => (0, utils_1.fileExists)(tracePath), { throwOnTimeout: false, wrapPredicateExecutionInsideTryCatch: true, }); // Then expect((0, utils_1.fileExists)(tracePath)).toBe(true); }); test('should handle multiple traces with chromium in headfull mode', async () => { // Given const browser = 'chromium'; const url = 'https://reactstrap.github.io'; const firstTracePath = path_1.default.join(__dirname, 'trace01.chromium.zip'); expect((0, utils_1.fileExists)(firstTracePath)).toBe(false); const secondTracePath = path_1.default.join(__dirname, 'trace02.chromium.zip'); expect((0, utils_1.fileExists)(secondTracePath)).toBe(false); const componentsTree = 'div#components'; const formsComponents = p .selector('div#storybook-explorer-tree') .find('button') .withText('Forms'); const storyBookIframe = 'iframe#storybook-preview-iframe'; const checkMeOut = p.selector('label').withText('Check me out').parent().find('input'); // When await p .withBrowser(browser) .withOptions({ headless: false }) .withTracing() .withCursor() .startTracing({ title: 'my first trace' }) .navigateTo(url) .stopTracingAndSaveTrace({ path: firstTracePath }) .startTracing({ title: 'my second trace' }) .hover(componentsTree) .hover(formsComponents) .click(formsComponents) .switchToIframe(storyBookIframe) .check(checkMeOut) .expectThatSelector(checkMeOut) .isChecked() .stopTracingAndSaveTrace({ path: secondTracePath }) .waitUntil(async () => (0, utils_1.fileExists)(secondTracePath), { throwOnTimeout: false, wrapPredicateExecutionInsideTryCatch: true, }); // Then expect((0, utils_1.fileExists)(firstTracePath)).toBe(true); expect((0, utils_1.fileExists)(secondTracePath)).toBe(true); }); });