Skip to content

Conversation

vjeux
Copy link
Contributor

@vjeux vjeux commented Sep 1, 2016

We disabled coverage in Travis because the implementation was crashing ( #6290 ). Since we upgraded to Jest 15, the entire coverage implementation is brand new so we should give it another try.

var grunt = require('grunt');
var path = require('path');

var rootPath = path.resolve('.');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this code path was really weird and not needed anymore. We can just run jest --coverage to do the same thing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's true. We want to exclude some files for sure, eg https://github.com/facebook/react/tree/355c49065386cbe33c026ba573c88c4e459ea328/src/shared/vendor/third_party (that file is showing up in the coverage report for this build). I'm also seeing coverage results for scripts/jest/test-framework-setup.js in the report.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jest has this annoying mode where you can either use the default where it runs coverage on all the files that are required by tests (the current mode) or you can manually specify all the files/folders you want to whitelist and blacklist.

My thinking was that outside of this thirty party component file, the rest is actually good. When I tried doing it on everything then it reported a bunch of useless stuff.

By the way, we don't need all that logic anymore, jest has a setting collectCoverageFrom in package.json that lets us configure it: https://github.com/facebook/jest/blob/master/package.json#L47

If you want to go through all the files and make it list only the things we care about, let me know.

"gulp-util": "^3.0.7",
"gzip-js": "~0.3.2",
"jest": "^15.0.1",
"jest": "^15.0.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed a bug with coverage and node 4

./node_modules/.bin/grunt jest:normal
fi
./node_modules/.bin/grunt jest:coverage
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is coveralls better than codecov? For Jest we now use Codecov and it comments on every PR with the coverage difference. It is nice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coveralls should do that too https://coveralls.io/features

@cpojer
Copy link
Contributor

cpojer commented Sep 1, 2016

oh man, this is so much simpler.

Does this run coverage on every PR or only on master? I think we should start collecting coverage on PRs too, possibly with codecov commenting on diffs.

If this passes on travis just fine, shall we merge it and see if it works well on PRs over the course of a day and potentially revert if there is trouble? I don't expect there to be any, but you know, all libraries have different, crazy tests. Overall, the Jest tests are very similar to React though.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling f51d0c9 on vjeux:fix_coverage into * on facebook:master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling f51d0c9 on vjeux:fix_coverage into * on facebook:master*.

@cpojer
Copy link
Contributor

cpojer commented Sep 1, 2016

omg it works.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e10e198 on vjeux:fix_coverage into * on facebook:master*.

@vjeux
Copy link
Contributor Author

vjeux commented Sep 1, 2016

Do you guys know if it's normal that it says "Changes Unknown" but manages to get the correct 67%?

Maybe it's because it's the first time it runs?

@gaearon
Copy link
Collaborator

gaearon commented Sep 1, 2016

Could be

@zpao
Copy link
Member

zpao commented Sep 1, 2016

Yea, probably fine. I'm guessing it's looking at the branch point and trying to find coverage for that commit but since we haven't had coverage on for a while it cant find anything.

@vjeux
Copy link
Contributor Author

vjeux commented Sep 1, 2016

Okay, here's my suggestion: we merge it in and see how it works in the next few prs that come in.

@zpao
Copy link
Member

zpao commented Sep 1, 2016

Please make sure you exclude files appropriately (I think my comment above may be getting lost since it's inline).

Edit: comment wasn't lost but I missed your response… We shouldn't include coverage results for things that aren't our code. Coverage should be reporting on React itself.

"<rootDir>/src",
"node_modules/fbjs"
],
"collectCoverageFrom": [
Copy link
Contributor Author

@vjeux vjeux Sep 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zpao I put back the old coverage paths, should be good to review

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 6681ad6 on vjeux:fix_coverage into * on facebook:master*.

@vjeux
Copy link
Contributor Author

vjeux commented Sep 2, 2016

Yay, 87%

We disabled coverage in Travis because the implementation was crashing ( facebook#6290 ). Since we upgraded to Jest 15, the entire coverage implementation is brand new so we should give it another try.
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 17139d7 on vjeux:fix_coverage into * on facebook:master*.

@vjeux
Copy link
Contributor Author

vjeux commented Sep 2, 2016

Thanks!

@vjeux vjeux added this to the 15-next milestone Sep 2, 2016
@vjeux vjeux merged commit 839697f into facebook:master Sep 2, 2016
acdlite pushed a commit to acdlite/react that referenced this pull request Sep 9, 2016
We disabled coverage in Travis because the implementation was crashing ( facebook#6290 ). Since we upgraded to Jest 15, the entire coverage implementation is brand new so we should give it another try.
@zpao zpao modified the milestones: 15-next, 15.4.0 Oct 4, 2016
zpao pushed a commit that referenced this pull request Oct 4, 2016
We disabled coverage in Travis because the implementation was crashing ( #6290 ). Since we upgraded to Jest 15, the entire coverage implementation is brand new so we should give it another try.
(cherry picked from commit 839697f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants