Skip to content

Commit

Permalink
Add codecov.io support back thanks to remap-istanbul
Browse files Browse the repository at this point in the history
- first Jest generates only `coverage-final.json` thanks to `"coverageReporters": ["json"]`
- then remap-istanbul rewrites `coverage-final.json` using the source maps
- and finally `istanbul report` generates `lcov-report` and `lcov.info`

See https://medium.com/@novemberborn/code-coverage-with-babel-istanbul-nyc-83b8c2f1093
  • Loading branch information
tkrotoff committed Aug 29, 2017
1 parent 35b3188 commit b581782
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
language: node_js
node_js:
- "7"
script:
- npm run coverage
after_success:
- npm install codecov
- codecov
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Simple form validation for React in [~350 lines of code](src/FormWithConstraints

[![npm version](https://badge.fury.io/js/react-form-with-constraints.svg)](https://badge.fury.io/js/react-form-with-constraints)
[![Build Status](https://travis-ci.org/tkrotoff/ReactFormWithConstraints.svg?branch=master)](https://travis-ci.org/tkrotoff/ReactFormWithConstraints)
[![codecov](https://codecov.io/gh/tkrotoff/ReactFormWithConstraints/branch/master/graph/badge.svg)](https://codecov.io/gh/tkrotoff/ReactFormWithConstraints)

- Installation: `npm install react-form-with-constraints`
- CDN: https://unpkg.com/react-form-with-constraints/dist/react-form-with-constraints.js
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"types": "lib/index.d.ts",

"scripts": {
"clean": "del-cli build lib dist/*.js",
"clean": "del-cli build lib dist/*.js coverage",

"preumd": "tsc",
"umd": "NODE_ENV=development browserify lib/index.js --external React --external ReactDOM --external PropTypes --standalone ReactFormWithConstraints --outfile dist/react-form-with-constraints.js",
Expand All @@ -25,8 +25,15 @@

"pretest": "npm run clean && tsc || true",
"test": "node --trace-warnings node_modules/.bin/jest --no-cache --verbose",

"coverage:remap:json": "remap-istanbul --input coverage/coverage-final.json --type json --output coverage/coverage-final.json",

"precoverage": "npm run pretest",
"coverage": "node --trace-warnings node_modules/.bin/jest --no-cache --coverage"
"coverage": "node --trace-warnings node_modules/.bin/jest --no-cache --coverage && npm run coverage:remap:json && istanbul report"
},

"jest": {
"coverageReporters": ["json"]
},

"dependencies": {
Expand Down Expand Up @@ -62,6 +69,7 @@

"jest": "latest",
"@types/jest": "latest",
"remap-istanbul": "latest",

"enzyme": "latest",
"@types/enzyme": "latest",
Expand Down

0 comments on commit b581782

Please sign in to comment.