UNPKG

e2ed

Version:

E2E testing framework over Playwright

31 lines (30 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setReadJsonReportDataObservers = setReadJsonReportDataObservers; 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 */ function 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); } }