denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97k stars 5.36k forks source link

feat: Add support for Cobertura XML coverage reporting #24595

Open patrickReiis opened 3 months ago

patrickReiis commented 3 months ago

Deno 1.45.2

I have this following script in my deno.json file:
{"test": "deno test -A --junit-path=./deno-test.xml"}

It creates this xml file which is nice, however when I open this file there's no code coverage, it only says the amount of time it took to run, here a random line to use as an example:

<testcase name="zap receipt does not have a &quot;description&quot; tag" classname="./src/pipeline.test.ts" time="0.017" line="60" col="6">

marvinhagemeister commented 3 months ago

Quoting the docs:

Deno will collect test coverage into a directory for your code if you specify the --coverage flag when starting deno test.

Does passing the --coverage flag to enable coverage collection when running the tests work?

patrickReiis commented 3 months ago

It creates a coverage directory that contains JSON files, not xml files.

I need it in xml files so I can use gitlab's feature, using the junit-path flag works but doesn't put the coverage inside the xml file.

marvinhagemeister commented 3 months ago

I see. Took a deeper look into this and it seems like JUnit doesn't support storing coverage data. I cannot find anything in the specs floating around the internet like https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd . They only deal with basic test reporting.

Looking at the documentation from GitLab it seems like are not expecting JUnit either, but rather a different format called Cobertura XML.

For the coverage analysis to work, you have to provide a properly formatted Cobertura XML report to artifacts:reports:coverage_report.

Right now we don't have a coverage reporter in Deno for the Cobertura XML format. Turning this issue into a feature request.

patrickReiis commented 3 months ago

Thank you very much!!