UNPKG

e2ed

Version:

E2E testing framework over Playwright

29 lines (28 loc) 944 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readPartOfJsonReportData = readPartOfJsonReportData; /** * 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 */ function 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; }