-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Code coverage failing with reading map file #21626
Comments
@ibrocodes7 It seems like your web page sources have broken source maps. I don't think Playwright can help with this. Look into your build tools/scripts for misconfigured source maps. |
In my case with Vite and Playwright, it is necessary to set the source map as inline in the Vite configuration in order to properly resolve the source map for Playwright code coverage.
export default defineConfig(() => {
return {
build: {
sourcemap: 'inline',
},
};
}); |
Same issue when i used the const v8toIstanbul = new V8toIstanbul(`the right source path here for loading source map file`, 0, sources, excludePath); so that's why inline sourcemap will works well. Therefore there are 2 solutions: // remove sourcemap link
import { removeMapFileComments } from 'convert-source-map';
source = removeMapFileComments(source) 2, manually load the sourcemap and pass it to const sourceMap = loadSourceMap(source);
const v8toIstanbul = new V8toIstanbul("", 0, {
source,
sourceMap
}, excludePath); |
System info
Source code
Link to the GitHub repository with the repro
[https://github.com/your_profile/playwright_issue_title]
or
Config file
Test file (self-contained)
Fixture
Console error:
Steps
Expected
I followed the instructions as per https://playwright.dev/docs/api/class-coverage to get the code coverage.
Actual
But I am facing an error complaining that the map is not present at the given location. This seems to be happening with latest version as well.
The text was updated successfully, but these errors were encountered: