Skip to content

Instantly share code, notes, and snippets.

@s14k51
Forked from novemberborn/coverage.sh
Created January 26, 2018 04:01
Show Gist options
  • Select an option

  • Save s14k51/ea8c1901317b6924e802cdd1e47207ab to your computer and use it in GitHub Desktop.

Select an option

Save s14k51/ea8c1901317b6924e802cdd1e47207ab to your computer and use it in GitHub Desktop.
Code Coverage with Babel, Istanbul & NYC
#!/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