-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Use source maps #18
Comments
Hm, I know very little about this. @bcoe - does Istanbul natively handle source maps? Is there a way we could do this? |
I'm also looking for this; my next step is to investigate babel-plugin-istanbul. edit: hmm, not what we're looking for, I think. |
It would be really nice if we could get code coverage from source maps used. |
@beaugunderson Istanbul stores coverage data in BTW: I tried replacing |
If files have sourcemaps, they will be linked when you run |
This is sorely needed. @aadityataparia there is no It might be related to puppeteer/puppeteer#3570 |
@stevenvachon the newest version of |
The combination of mocha + cypress + nyc has coverage issues for Vue SFC. Jest has better coverage support and puppeteer is much faster than cypress. However, it's difficult to make puppeteer activate coverage for E2E tests. The coverage is just for unit tests until there is a solution. See also: argos-ci/jest-puppeteer#90 istanbuljs/puppeteer-to-istanbul#18
The combination of mocha + cypress + nyc has coverage issues for Vue SFC. Jest has better coverage support and puppeteer is much faster than cypress. However, it's difficult to make puppeteer activate coverage for E2E tests. The coverage is (still) just for unit tests until there is a solution. See also: argos-ci/jest-puppeteer#90 istanbuljs/puppeteer-to-istanbul#18
The combination of mocha + cypress + nyc has coverage issues for Vue SFC. Jest has better coverage support and puppeteer is much faster than cypress. However, it's difficult to make puppeteer activate coverage for E2E tests. The coverage is (still) just for unit tests until there is a solution. See also: argos-ci/jest-puppeteer#90 istanbuljs/puppeteer-to-istanbul#18
Without this, the tool is not really useable unfortunately if you're using any bundler like webpack :/ |
@stevenvachon could you please tell how to use c8 instead of nyc? |
@SergeyPirogov I will have to retract my above statement due to bcoe/c8#162 |
@bcoe could you please help, I see that puppeteer to Istanbul use v8 to istanbul under the hood. How to map coverage to the original source? |
So.. I've been trying to get this working. I re-wrote this package to use the latest Sorry but this is typescript and in POC stage..
However I then discovered that So I started a POC to add that support to I gave up trying to make it work with a minifier - the mappings were too extreme. Without minification it seems to be creating the right ranges in the right files, but its not doing very well at converting those ranges into branches, lines and statements - I seem to always end up with 100% coverage. I'm pretty close to giving up on v8 coverage and just instrumenting with istanbul.. |
So it turns out that the report given by pupeteer and playwright is just missing too much information to be used with with pupeteer-to-istanbul. I copied the coverage class from playwright, fixed the imports back to the right place and changed it to return the raw v8 information. piping that into v8-to-istanbul directly gives good coverage. |
@lukeapage interesting, what bumps into issues? also thanks for digging into this, unfortunately I write almost no frontend code these days and have been a poor steward of this library. |
Because it merges ranges it squashed branches and functions. Because callCount is false, you don’t get 0 count ranges so defaulting the line count to 1 means 100% line coverage Looks like playwright at least will soon expose the raw v8 info. |
I have same issue and the above @lukeapage @bcoe 's comments help me much.
Puppeteer edits raw V8 coverage result via https://github.com/puppeteer/puppeteer/blob/main/src/common/Coverage.ts#L382 . I think Puppeteer should expose raw V8 script coverages as Playwrite does. puppeteer/puppeteer#6454 |
Is there a solution to this issue or any alternatives? |
@smokku suggestion worked for me. Background
Steps
Then based on the link @smokku provided: AfterAll(async function () {
const outputDir = "../.nyc_output";
// eslint-disable-next-line no-underscore-dangle
const coverage = await page.evaluate(() => window.__coverage__);
await fs.emptyDir(outputDir);
await Promise.all(
Object.values(coverage).map(cov => {
if (
cov &&
typeof cov === "object" &&
typeof cov.path === "string" &&
typeof cov.hash === "string"
) {
return fs.writeJson(`${outputDir}/${cov.hash}.json`, {
[cov.path]: cov,
});
}
return Promise.resolve();
})
);
// Make sure the browser is closed
if (browser != null) {
browser.close();
}
}); That generates the Then in the project root:
Result
Versions Used
|
Is there any solution that works with webpack bundler as well? |
Is there any solution for this? |
Hi,
I don't really understand how this package works so I apologise in advance if this isn't the right place to make this question.
On my project, the code that reaches the browser is processed by babel. The final code has source maps that google chrome uses to show the original source when I open the dev tools. However the puppeteer coverage information of a file shows the processed source code, not the original. Is there a way to convert the
text
andranges
fields of the coverage object to the original source and line numbers?Thank you for your antention
The text was updated successfully, but these errors were encountered: