Skip to content

Commit

Permalink
Add test coverage with istanbul ...
Browse files Browse the repository at this point in the history
* Add npm script `cover`, which calls istanbul:
  * Do not execute `istanbul` via `babel-node`, this is deprecated, instead use `babel-register` as an argument to `mocha` (credit: gotwarlost/istanbul#594 (comment))
  * Use `--root src/` to fix issue where istanbul also attempts to cover `mocha` (credit: douglasduteil/isparta#68 (comment))
  * Use `--include-all-sources` to make the coverage percentages actually meaningful by including sources that didn't get executed

* In `src/higher_order_components/errors_normalizer.js`, make minor change to return statement. This form: `if (foo) return { a: 'b' }` seems to have confused Istanbul's coverage highlighter. There are other cases like this, that are bugs in Istanbul (e.g. gotwarlost/istanbul#557). Probably worth making a repro case for this and reporting to them.
  • Loading branch information
jbinto committed Apr 13, 2016
1 parent 91ea661 commit 79a4e3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ bower_components

npm-debug.log
.DS_Store

coverage
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test:watch": "npm run test -- --watch --watch-extensions js",
"lint": "eslint src/ test/ || true",
"lint:failfast": "eslint src/ test/",
"cover": "istanbul cover --root src/ --include-all-sources --report lcov --report json --report text --report html _mocha -- -r babel-register -r test/test_helper.js 'test/**/*.test.js'",
"preversion": "./scripts/preversion.sh",
"version": "./scripts/version.sh",
"postversion": "./scripts/publish_docs.sh && git push && git push --tags"
Expand All @@ -28,6 +29,7 @@
"babel-preset-es2015": "6.6.0",
"babel-preset-react": "6.5.0",
"babel-preset-stage-1": "6.5.0",
"babel-register": "^6.7.2",
"chai": "3.5.0",
"chai-enzyme": "^0.4.1",
"dirty-chai": "^1.2.2",
Expand All @@ -37,13 +39,14 @@
"eslint-plugin-react": "4.2.3",
"extract-text-webpack-plugin": "1.0.1",
"fs-extra": "0.26.7",
"istanbul": "^1.0.0-alpha.2",
"jsdom": "8.2.0",
"jsx-loader": "0.13.2",
"mkpath": "1.0.0",
"mocha": "2.4.5",
"react": ">=0.14.3",
"react-dom": ">=0.14.3",
"react-addons-test-utils": "^0.14.8",
"react-dom": ">=0.14.3",
"webpack": "1.12.14",
"webpack-dev-server": "1.14.1"
},
Expand Down
4 changes: 3 additions & 1 deletion src/higher_order_components/errors_normalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export default class ErrorNormalizer extends React.Component {
// If errors is an array then convert it into an object. 'base' is
// used to store all top-level errors that are not specific to an
// input.
if (isArray) return { base: errors }
if (isArray) {
return { base: errors }
}

return errors
}
Expand Down

0 comments on commit 79a4e3b

Please sign in to comment.