playwright
playwright copied to clipboard
[BUG] the coverage and sourceMappingURL don't work if the js added with `addScriptTag`
System info
- Playwright Version: [^1.41.0]
- Operating System: [Windows 10]
- Browser: [Chromium]
Source code
Example js, path is: .temp/my.js and content:
console.log("my js content with sourceMappingURL comments");
//# sourceMappingURL=my.js.map
Steps
const page = await browser.newPage();
await page.coverage.startJSCoverage();
await page.addScriptTag({
path: '.temp/my.js'
});
const jsCoverage = await page.coverage.stopJSCoverage();
console.log(jsCoverage); // got nothing
However, the coverage data exists if enabled reportAnonymousScripts
await page.coverage.startJSCoverage({
reportAnonymousScripts: true
});
But the source becomes:
console.log("my js content with sourceMappingURL comments");
//# sourceMappingURL=my.js.map//# sourceURL=.temp/my.js
Note, the last line breaks sourceURL and sourceMappingURL
Expected
- the coverage should work without
reportAnonymousScripts - the sourceMappingURL should work too