[Architecture] Integrating Testem and Istanbul...
tony at raisingthefloor.org
Wed May 11 10:11:04 UTC 2016
As you may remember from other discussions, I have been using Testem
<https://github.com/testem/testem> more often these days to test
client-side components. It seemed less than ideal to talk about setting
coverage standards for PRs without having some idea of how to measure test
coverage for projects that use Testem.
Thankfully, Testem provides a sample project that demonstrates integration
This morning I adapted their example to add test coverage reporting to
gpii-binder. The work is visible here in this branch:
To summarize, their approach is to:
1. Use Istanbul to instrument the source code under test before running
2. Set up a server in testem.js that serves up the instrumented code and
listens for and saves coverage reports.
3. Configure the client-side Testem to send reports to the server after
each test completes.
4. Examine the coverage report when all tests complete.
This approach requires small changes to your test HTML, namely using the
instrumented version of the code you're testing, and loading code that
handles step 3 (my example is here
It also can only possibly work if you are using a testem.js file, which
means you'd need to port over any settings you might have in your existing
testem.json or testem.yml file.
With all this extra wiring, a coverage report is generated whenever npm
test is run, without requiring either Testem or Istanbul to be installed
Anyway, I share in case anyone else is heading even partway down the same
road. If your projects use Testem and you'd like to discuss generalizing
anything discussed here, please get in touch.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Architecture