Created
November 26, 2015 12:11
-
-
Save novemberborn/e133e9edabbb380229ca to your computer and use it in GitHub Desktop.
Code Coverage with Babel, Istanbul & NYC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Shell script to compute code coverage even after the Babel transforms have | |
# been applied. | |
# Clear previous coverage. | |
rm -rf coverage | |
# Generate test coverage based on however `npm test` performs the tests. | |
nyc --reporter=json npm test | |
# Move generated JSON file so it can be remapped and won't confuse Istanbul | |
# later. | |
mv coverage/coverage-final.json coverage/coverage.json | |
# Rewrite the coverage file taking the Babel source maps into account. | |
remap-istanbul -i coverage/coverage.json -o coverage/coverage.json | |
# Generate an lcov.info file and an HTML report, and output a text report. | |
istanbul report lcov text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment