lucassabreu / comment-coverage-clover

Github Action that automatically adds a comment with a summary of coverage reports (clover)
https://github.com/marketplace/actions/coverage-report-as-comment-clover
16 stars 4 forks source link

Support for Jest generated reports #27

Closed jacekk closed 1 year ago

jacekk commented 1 year ago

I've used this tool in a React project in which Jest is being used for code coverage reporting. There are, sadly, two problems with the main branch. Thus, introduced some improvements. Problems:

A) file entry in clover.xml contains name and path attributes. name is just the file name with extension. While path contains the full file system path. Example:

<file name="file-one-A.js" path="/home/foo/bar-project/src/dir-one/file-one-A.js">

B) The xml2json package is not returning a list of files, when only a single spec is within given directory. Namely, not this:

package?: { file: CloverFileXML[] }[];

but this:

package?: { file: CloverFileXML | CloverFileXML[] }[];

seem to be the right type.


Both these issues have been fixed in this PR. Reproduced and tested in the following changsets, which are identical when it comes to modified spec files. The difference is in workflows; negligible change.

Broken:

https://github.com/jacekk/comment-coverage-clover--jest-support/pull/1

image


Fixed:

https://github.com/jacekk/comment-coverage-clover--jest-support/pull/2

image


In summary:

Additionally, filters === [] seems to be always false - JS is reference-based for objects and arrays.

lucassabreu commented 1 year ago

thank you for the contribution @jacekk