An example project demonstrating code coverage for Gleam using the Node.js test coverage reporter and lcov.
- A Node.js installation that supports
--experimental-test-coverage
lcov
andgenhtml
(both from the lcov package)- just to run the build scripts (though you could port it to
make
or run the scripts manually)
Note! Before doing anything, you may need to adjust extract
and remove
options in the justfile
to better reflect your project structure.
First ensure all tests are passing (just test_js
or gleam test --target=javascript
). Running the coverage report in the presence of failing tests does not give you good output to diagnose any problems.
Once the test suite is all green, run just cov_js
to generate a coverage report. If all goes well, the report will be located in ./_coverage/html/index.html
, ready to be opened in your favorite web browser.
You will see that this project has some nesting and submodules and stuff, just to demonstrate that the filtering of the coverage output files works as expected.
Here is an example of what the reports look like:
As you can see, code coverage is shown for the generated JavaScript output rather than the Gleam source files, but it's still helpful.
To the extent possible under law, Ryan M. Moore has waived all copyright and related or neighboring rights to this project.
If for whatever reason, CC0 will not work for your project, you may use MIT or the Unlicense.