-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
test_runner: lcov reporter for test coverage #49626
Comments
I think this is a good idea, my only concern is source map support |
VSCode, as well as many extensions (e.g. I support and want this. |
That's certainly important. But should that be handled before the And if that is the case, a reporter can be built independently of source map support. And the feature only graduates from experimental when it has source map support. |
my comment wasn't made to block or object to this feature - just to raise this as something to think about before the feature is implemented. if it is possible to map lcov format after it is generated to its source that works as well |
Thanks @MoLow, I will certainly keep it in mind. |
This is a fantastic feature to have in node! As a workaround I've used this for now NODE_V8_COVERAGE=./coverage c8 -r html node --test --experimental-test-coverage src/**/*.spec.ts |
Fixes nodejs#49626 PR-URL: nodejs#50018 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
@philnash thank you for adding lcov support! |
@fernandopasik there's certainly nothing wrong with raising a feature request for an HTML coverage report. The only issue I see with it is that it wouldn't necessarily fit with the model of existing reporters, in that you normally define a single output file and an HTML report would require multiple files, normally going into a coverage directory of its own. |
It's a very good point. A note also on this is some of the lcov reporters in other runners like jest and mocha do generate the html output files in the same directory than the lcov.info file. I tried to mitigate requesting for this by using a package to generate html report from the lcov file, but I was unsuccessful, not sure if you have any good alternatives for this. |
What package did you try and what was unsuccessful about it? I haven't actually tried that myself yet, but it's something I'd be happy to look into. |
Sorry I should have said it didn't work for my particular problem 😊 I haven't tried it with js files, it didn't work with some typescript project I was working on, but I was hoping you might known an alternative package I could try. The issue I was having was that I could not explore in detail each file in the lcov.info file |
Ah, my understanding is that coverage still doesn't work accurately for TypeScript because the coverage system doesn't yet support source maps. |
Oh thanks! By any chance do you know an issue in this repo about it that I can follow? |
What is the problem this feature will solve?
We can now produce code coverage reports from the built-in test runner and (currently experimental) code coverage. Being able to report that coverage to third-parties, like SonarQube, SonarCloud, Coveralls, or Code Climate is useful to track coverage over time.
Each of these tools accepts lcov as a format for providing test coverage results.
What is the feature you are proposing to solve the problem?
I propose to write a test reporter that outputs code coverage results in the lcov format.
I've actually got quite a long way through this, as part of adding more information to the
test:coverage
event sent to reporters. I don't wish the reading of the lcov documentation on anyone else.I did want to raise a feature request to see if there were any comments or thoughts before I open a PR.
What alternatives have you considered?
This could be built as a third-party module, but given lcov's seeming ubiquity as the code coverage format of choice for different code quality tools, it would be useful for users to have it built in.
In comparison with other platforms, Deno can generate an lcov report from its coverage output and Bun has an open issue to implement lcov, so this is becoming par for the course for a test runner.
I am happy to work on this. Full disclosure, I work at Sonar and this would be beneficial to our users if they decide to choose to use the Node test runner in their projects.
The text was updated successfully, but these errors were encountered: