UNPKG

e2ed

Version:

E2E testing framework over Playwright

22 lines (21 loc) 937 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.takeScreenshot = void 0; const node_path_1 = require("node:path"); const internal_1 = require("../constants/internal"); const useContext_1 = require("../useContext"); const log_1 = require("../utils/log"); /** * Takes a screenshot of the tested page. */ const takeScreenshot = async (options = {}) => { const { path: pathToScreenshot, ...optionsWithoutPath } = options; (0, log_1.log)('Take a screenshot of the page', { pathToScreenshot, ...optionsWithoutPath }, 5 /* LogEventType.InternalAction */); if (pathToScreenshot !== undefined) { // eslint-disable-next-line no-param-reassign options.path = (0, node_path_1.join)(internal_1.SCREENSHOTS_DIRECTORY_PATH, pathToScreenshot); } const page = (0, useContext_1.getPlaywrightPage)(); await page.screenshot(options); }; exports.takeScreenshot = takeScreenshot;