* Inject the harness server's log-capture probe (the same shim * ``run-javascript-browser-tests.sh`` uses for the screenshot * suite) into ``index.html``. Without it, console output never * makes it into ``browser.log`` — Playwright still sees the * messages directly via ``page.on('console')`` s
(indexHtml)
| 136 | * report has nothing for a CI consumer to grep through. |
| 137 | */ |
| 138 | function injectProbeScript(indexHtml) { |
| 139 | if (!fs.existsSync(indexHtml)) return; |
| 140 | let text = fs.readFileSync(indexHtml, 'utf8'); |
| 141 | const probe = '<script src="/__cn1__/probe.js"></script>'; |
| 142 | if (text.indexOf(probe) >= 0) return; |
| 143 | const bridge = '<script src="browser_bridge.js"></script>'; |
| 144 | if (text.indexOf(bridge) >= 0) { |
| 145 | text = text.replace(bridge, probe + '\n' + bridge); |
| 146 | } else if (text.indexOf('</body>') >= 0) { |
| 147 | text = text.replace('</body>', probe + '\n</body>'); |
| 148 | } else { |
| 149 | text += '\n' + probe + '\n'; |
| 150 | } |
| 151 | fs.writeFileSync(indexHtml, text, 'utf8'); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Walk into the bundle directory and return the directory containing |