zordius / gulp-jsx-coverage

deprecated
https://www.npmjs.com/package/gulp-jsx-coverage
Other
34 stars 10 forks source link

Branch and Statements coverage is off with React components #24

Closed cliren closed 8 years ago

cliren commented 8 years ago

Firstly thanks for continuous support!

If you take a look at this example https://github.com/cliren/react-jsx-coverage-example and inspect coverage, for coverage/lcov-report/src/react-components/UserProfileLink.jsx.html, you will the see below lines. The actual code (lines, branches and statements) are 100% covered but looks like the tool is taking the transformed code into consideration and lowering the branch and statement coverage. Is there a way to ignore it and have the coverage reflect the actuals?

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { Iif (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { Iif (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
zordius commented 8 years ago

Will check this later, thank you for your report!

zordius commented 8 years ago

This is a test done by unmodified istanbul , so the report will be transpiled code.

If you like to see untouched code in the report, you can try isparta.

I try to update the example here: https://github.com/zordius/react-jsx-coverage-example , the report showed original code but coverage 100%....strange. Then I found there are some issues in isparta now ( https://github.com/douglasduteil/isparta/issues/96 , https://github.com/douglasduteil/isparta/issues/99 https://github.com/douglasduteil/isparta/issues/108 ) .....So far I can not fix this and still need to wait for new isparta or istanbul.

cliren commented 8 years ago

Ya, I checked your example, its strange! I will wait for it and thanks for looking into this.

cliren commented 8 years ago

I was waiting for a fix from isparta, doesn't look like its out yet. Here is what I found latest:

Example coverage:

The culprit line in the below coverage report is the line: var _extends = Object.assign || function (target) { ...

https://github.com/cliren/react-jsx-coverage-example/blob/master/coverage/lcov-report/src/react-components/UserProfileLink.jsx.html

Its caused by the es6 spread operator

<a href={this.props.linkUrl} {...additionalProps}>{this.props.linkText}</a>

Any thoughts on how we can exclude this in istanbul report ?

cliren commented 8 years ago

Applying 'transform-runtime' helped with the ES6 spread operator. There are few other transpilations which have the same issue. I will check appropriate babel plugins and apply them. Closing this as know the root cause.