puppeteer-to-istanbul icon indicating copy to clipboard operation
puppeteer-to-istanbul copied to clipboard

fix: map paths back to original file paths

Open dword-design opened this issue 3 years ago • 3 comments

Hey folks,

I like this package and it solves a lot of my code coverage problems in frontend testing!

One problem with the current implementation is that the coverage is actually measured on different files than the original ones. This works rather fine when you only measure coverage over visited files. However, it leads to problems when you e.g. work with the nyc --all option and you want to be precise with the covered files.

While it is necessary to write the generated webpack files to disk for v8-to-istanbul, we actually do not need to pass the coverage data on as-is. We can convert them back to their original paths and have nice and consistent coverage data.

The current proposal is kinda the idea, there are failing tests and I need some feedback from contributors who are deeper into the topic. Also, the implementation with the for loops is a bit error prone, I'd prefer a non-mutating solution here.

Would love to have this integrated. For me it's working fine!

dword-design avatar Mar 12 '21 11:03 dword-design

I added a commit that also applies source maps, so now we have coverage that matches the original file's lines.

dword-design avatar Mar 19 '21 14:03 dword-design

@dword-design hey 👋 sorry for the slow review, got a bit behind on GitHub.

I don't do much frontend coding these days I'm afraid, so I'm willing to defer to your expertise (as an active user of the module). If we can get tests passing, I'm open to your proposal.

bcoe avatar Apr 07 '21 18:04 bcoe

@bcoe Alright. I think it needs some more work, also regarding the tests. I'll keep pushing stuff in here and if it has a stable state, I'll write it here. I'm not (or wasn't) a big expert in code coverage, so I'm getting into the topic by this. Would be great to have a library that reflects covered code in puppeteer back to the original source files.

dword-design avatar Apr 09 '21 09:04 dword-design