UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

31 lines 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.test = void 0; const test_1 = require("@playwright/test"); const _1 = require("."); const ConsoleErrorHelper_1 = require("./ConsoleErrorHelper"); const test = test_1.test.extend({ umbracoApi: async ({ page }, use) => { const umbracoApi = new _1.ApiHelpers(page); // Runs the isLoginStateValid before each implementation of umbracoApi in our tests (Which is every single one). This makes sure that the login state is valid await umbracoApi.isLoginStateValid(); await use(umbracoApi); }, umbracoUi: async ({ page }, use) => { const umbracoUi = new _1.UiHelpers(page); const consoleErrorHelper = new ConsoleErrorHelper_1.ConsoleErrorHelper(); // Listen for all console events and handle errors page.on('console', message => { if (message.type() === 'error') { const errorMessage = message.text(); const testTitle = test.info().title; const testLocation = test.info().titlePath[0]; let errorMessageJson = consoleErrorHelper.updateConsoleErrorTextToJson(errorMessage, testTitle, testLocation); consoleErrorHelper.writeConsoleErrorToFile(errorMessageJson); } }); await use(umbracoUi); } }); exports.test = test; //# sourceMappingURL=testExtension.js.map