Any tools to measure coverage of `stack test`?

Hi,

I’m introducing a new PureScript frontend to production and there is a requirement for all the new code deployed to have a test coverage >60%. Is there any tool that could help me with checking a coverage of spago test? Or am I going to need to write such tool myself?

Scanning a JS bundle is not an option of course as it pulls in a big chunk of dependencies’ code that does not belong to the project.

4 Likes

You’ll likely need to write a tool yourself.

I believe there were efforts before that involved hooking into the generated source maps, but this was roughly 3 years ago Question - Adding support for PureScript · Issue #1081 · istanbuljs/nyc · GitHub

Check out c8; c8 spago test works for me with PureScript 0.14 and the upcoming 0.15 with ES modules support! As long as all your project modules use a unique module prefix, you can use "output/MyApp.*/*.js" as the include directive in config or on the command line and that will exclude your dependencies.

6 Likes

I don’t have a unique module prefix, but I wrote a short script that would generate include config traversing src/ recursively and feed it to c8. That works, thank you very much!

2 Likes