UNPKG

playwright-fluent

Version:
67 lines (66 loc) 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path = tslib_1.__importStar(require("path")); const simple_fake_server_1 = require("simple-fake-server"); const SUT = tslib_1.__importStar(require("../../playwright-fluent")); const devices_1 = require("../../../devices"); describe('Playwright Fluent - recordVideo()', () => { let p; let fakeServer = undefined; beforeAll(() => { fakeServer = new simple_fake_server_1.FakeServer(1247); fakeServer.start(); //The FakeServer now listens on http://localhost:1247 }); afterAll(() => { if (fakeServer) { fakeServer.stop(); } }); beforeEach(() => { p = new SUT.PlaywrightFluent(); }); afterEach(async () => { await p.close(); }); test('should record video', async () => { // Given const url = `file:${path.join(__dirname, 'record-video.test.html')}`; const responseBody = { prop1: 'foobar', }; const responseBodyBaz = { prop1: 'foobaz', }; const responseHeaders = { 'foo-header': 'bar', }; fakeServer && // prettier-ignore fakeServer.http .get() .to('/foobar') .willReturn(responseBody, 200, responseHeaders); fakeServer && // prettier-ignore fakeServer.http .get() .to('/yo') .willReturn(responseBodyBaz, 200, responseHeaders); // When await p .withBrowser('chromium') .withOptions({ headless: true }) .withWindowSize(devices_1.sizeOf._1024x768) .withCursor() .clearVideoFilesOlderThan(__dirname, 60) .recordVideo({ dir: __dirname, size: devices_1.sizeOf._1024x768 }) .navigateTo(url) .wait(3000) .close(); // Then video path should be available const videoPath = await p.getRecordedVideoPath(); expect(videoPath).toBeDefined(); }); });