I am running tests and collecting coverage with Vitest configured to use the c8
coverage library. This seems to be working because when the tests finish, I get a coverage report in the terminal and a directory named coverage
is created with all sorts of files I can look at in a browser:
$ ls -la coverage/
total 712
drwxr-xr-x 14 shawn staff 448 Apr 10 11:08 .
drwxr-xr-x 24 shawn staff 768 Apr 10 11:23 ..
-rw-r--r-- 1 shawn staff 5394 Apr 10 11:08 base.css
-rw-r--r-- 1 shawn staff 2655 Apr 10 11:08 block-navigation.js
-rw-r--r-- 1 shawn staff 108109 Apr 10 11:08 clover.xml
-rw-r--r-- 1 shawn staff 190921 Apr 10 11:08 coverage-final.json
drwxr-xr-x 4 shawn staff 128 Apr 10 11:08 examples
-rw-r--r-- 1 shawn staff 445 Apr 10 11:08 favicon.png
-rw-r--r-- 1 shawn staff 5802 Apr 10 11:08 index.html
-rw-r--r-- 1 shawn staff 676 Apr 10 11:08 prettify.css
-rw-r--r-- 1 shawn staff 17590 Apr 10 11:08 prettify.js
-rw-r--r-- 1 shawn staff 138 Apr 10 11:08 sort-arrow-sprite.png
-rw-r--r-- 1 shawn staff 6181 Apr 10 11:08 sorter.js
drwxr-xr-x 11 shawn staff 352 Apr 10 11:08 src
My next step is to send this coverage information along to Coveralls to get a coverage badge for my README. For this part, I'm using the GitHub Action provided by Coveralls for this use-case: coverallsapp/github-action@v2
This doesn't work, however: it seems the action is not finding the coverage report since it says "Nothing to report".
Here are the relevant parts of the deployment workflow:
[…]
test:
[…]
steps:
[…]
- name: Test
run: npm test
env: […]
- name: Report Coveralls
uses: coverallsapp/github-action@v2
The npm test
part creates the coverage
directory (it basically just runs vitest run --coverage
).
So why is Coveralls not finding the coverage report? Should I be configuring c8
to produce a different format of output? Do I need extra configuration when calling coverallsapp/github-action@v2
? Should I be using istanbul
instead of c8
, or perhaps something else? Should I be using CodeDov instead of Coveralls, or perhaps something else?