UNPKG

e2ed

Version:

E2E testing framework over Playwright

30 lines (29 loc) 991 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readPartOfJsonReportData = void 0; /** * Reads part of JSON report data from script tag. * Returns `true` if read successfully, and `false` if it has parse errors. * This client function should not use scope variables (except global functions). * @internal */ const readPartOfJsonReportData = ({ scriptToRead, shouldLogError }) => { try { const data = JSON.parse(scriptToRead?.textContent ?? ''); if ('apiStatistics' in data) { reportClientState.reportClientData = data; } else { reportClientState.fullTestRuns.push(...data); } } catch (error) { if (shouldLogError) { // eslint-disable-next-line no-console console.error('Cannot parse JSON report data from script', error); } return false; } return true; }; exports.readPartOfJsonReportData = readPartOfJsonReportData;