UNPKG

e2ed

Version:

E2E testing framework over Playwright

32 lines (31 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setReadJsonReportDataObservers = void 0; const readJsonReportData_1 = require("./readJsonReportData"); const readJsonReportData = readJsonReportData_1.readJsonReportData; /** * Set mutation observers for reading JSON report data. * This client function should not use scope variables (except global functions). * @internal */ const setReadJsonReportDataObservers = () => { const observeChildList = { childList: true }; const { readJsonReportDataObservers } = reportClientState; const scriptsObserver = new MutationObserver(() => readJsonReportData()); readJsonReportDataObservers.push(scriptsObserver); if (document.body !== undefined) { scriptsObserver.observe(document.body, observeChildList); } else { const htmlObserver = new MutationObserver(() => { const body = document.querySelector('body'); if (body) { scriptsObserver.observe(body, observeChildList); htmlObserver.disconnect(); } }); readJsonReportDataObservers.push(htmlObserver); htmlObserver.observe(document.documentElement, observeChildList); } }; exports.setReadJsonReportDataObservers = setReadJsonReportDataObservers;