Add code coverage reports npm script

Generate code coverage reports based on the node-qunit tests with
istanbul.

Changes:
* Update README with npm run coverage
* Add .istanbul.yml to configure istanbul
* Add npm script "coverage" that runs istanbul and generates the reports

Example report: http://popups-coverage.surge.sh/lcov-report/index.html

Change-Id: I9be8c04b858a3ce6f4e29af2685b79253e3b4dca
This commit is contained in:
joakin 2017-03-03 13:34:33 +01:00
parent c7951484b7
commit 04fbc9dea2
4 changed files with 15 additions and 2 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
/docs/
/coverage/
/node_modules/
/vendor/
/composer.lock

8
.istanbul.yml Normal file
View file

@ -0,0 +1,8 @@
instrumentation:
include-all-sources: true
excludes: [
"resources/dist/*", # Compiled assets
"*.js", # Gruntfile.js and webpack.config.js
"src/processLinks.js", # Covered by browser QUnit integration test
"src/index.js", # Application entry point
]

View file

@ -31,3 +31,5 @@ After an `npm install`:
* `npm install -g nodemon`
* Example running linting and node unit tests:
* `nodemon -w src/ --exec "grunt lint:all && npm run test:node"`
* Get code coverage report with `npm run coverage`
* Reports printed in the `coverage/` folder

View file

@ -6,7 +6,8 @@
"test": "grunt lint && npm run check-built-assets && npm run test:node",
"doc": "jsduck",
"check-built-assets": "echo 'CHECKING BUILD SOURCES ARE COMMITED' && rm -rf test-build && mv resources/dist test-build && npm run build && diff -x '*.map' -r test-build resources/dist && rm -rf test-build",
"test:node": "mw-node-qunit tests/node-qunit/*.js tests/node-qunit/**/*.js | tap-dot"
"test:node": "mw-node-qunit tests/node-qunit/*.js tests/node-qunit/**/*.js | tap-dot",
"coverage": "istanbul cover node_modules/.bin/mw-node-qunit tests/node-qunit/*.js tests/node-qunit/**/*.js"
},
"devDependencies": {
"eslint-config-wikimedia": "0.3.0",
@ -18,8 +19,9 @@
"grunt-eslint": "19.0.0",
"grunt-jsonlint": "1.1.0",
"grunt-stylelint": "^0.6.0",
"mw-node-qunit": "^1.0.6",
"istanbul": "^0.4.5",
"mock-require": "^2.0.1",
"mw-node-qunit": "^1.0.6",
"redux": "3.6.0",
"redux-thunk": "2.2.0",
"stylelint-config-wikimedia": "0.3.0",