UNPKG

playwright-fluent

Version:
45 lines (44 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); const utils_1 = require("../../../utils"); const SUT = tslib_1.__importStar(require("../../playwright-fluent")); describe('Playwright Fluent - recordNetworkActivity()', () => { let p; beforeEach(() => { p = new SUT.PlaywrightFluent(); }); afterEach(async () => { await p.close(); }); test('should return an error when no path has been set', async () => { // Given // When let result = undefined; try { await p.recordNetworkActivity({ path: '' }); p.getRecordedNetworkActivity(); } catch (error) { result = error; } // Then expect(result && result.message).toContain("HAR filepath has not been setup. Ensure you have called 'recordNetworkActivity({path: <valid file path>})'."); }); test('should return an error when browser has not been closed', async () => { // Given const harFilepath = `${path_1.default.join(__dirname, (0, utils_1.uniqueFilename)({ prefix: 'har-', extension: '.json' }))}`; // When let result = undefined; try { await p.recordNetworkActivity({ path: harFilepath }); p.getRecordedNetworkActivity(); } catch (error) { result = error; } // Then expect(result && result.message).toContain(`File '${harFilepath}' does not exist. Ensure you have called 'recordNetworkActivity({path: ${harFilepath}})' and that you have closed the browser. HAR data is only saved to disk when the browser is closed.`); }); });