Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CodeCov shield for create react app #631

Closed

Conversation

MichaelDimmitt
Copy link
Collaborator

I will be adding to the documentation for this pull request after it has been merged or closed. To improve readability of the process for setting code coverage up on a create react app.

link1: code coverage from create react app issues page
link2: code coverage from create react app docs
link3: use yarn test instead of npm test

Lastly, codecov needed to be installed to get the shield.
Codecov is a global npm package installed when running TravisCI or CircleCI that hosts your previous and current code coverage information to show the projects progression over time.
Running codecov after the files have been written to the coverage folder, sends the coverage folder info to the codecov website. This service is free for open source projects.

@MichaelDimmitt MichaelDimmitt changed the title WIP: responding to some instructions for create react Add CodeCov shield for create react app. Jul 4, 2018
@MichaelDimmitt MichaelDimmitt changed the title Add CodeCov shield for create react app. Add CodeCov shield for create react app Jul 4, 2018
@MichaelDimmitt MichaelDimmitt force-pushed the attempt-code-cov branch 2 times, most recently from 933ee76 to b013781 Compare July 4, 2018 21:34
@MichaelDimmitt
Copy link
Collaborator Author

MichaelDimmitt commented Jul 4, 2018

to see the shield working in practice checkout my dev branch:
https://github.com/MichaelDimmitt/cliff-effects

Otherwise the shield will say unknown until the commit is accepted and the test suite passes again.
Happy to make any changes if there are any issues/ additions wanted.

@knod
Copy link
Collaborator

knod commented Jul 5, 2018

Sorry, hectic times for me. If no one else manages to catch this sooner, I'll run this over when I get a chance! Thanks!

@wacii
Copy link
Collaborator

wacii commented Jul 6, 2018

Looks good. I would probably leave out the --coverage flag, to reduce clutter in the Travis build, assuming it isn't required for something else. But that is a minor concern.

This would certainly be nice to have though, now that we have people working on tests.

@knod
Copy link
Collaborator

knod commented Jul 6, 2018

@MichaelDimmitt : Thoughts on the --coverage? Pros and cons?

@MichaelDimmitt
Copy link
Collaborator Author

MichaelDimmitt commented Jul 6, 2018

@wacii, @knod,
There are a few ways to handle --coverage.
Apologies in advance for opening so many pr's for this enhancement.
Only one needs to be chosen.

  1. Add CodeCov shield for create react app #631, this pull request: npm run test -- --coverage inside the .travis.yml
  2. Add Code coverage command  #632, same as this pr but adding coverage script to the package.json:
    npm run coverage. Additionally the .travis.yml could npm run coverage but I feel that is against convention because someone might decide to delete the coverage script one day.
  3. Add code coverage to test script in package.json #634, Change the test command in package.json to:
    "test": "react-scripts test -- --coverage",
    then the .travis.yml only needs to perform npm run test

@wacii
Copy link
Collaborator

wacii commented Jul 6, 2018

Alright, I think I misunderstood exactly how this works. It is jest that collects the coverage information, the --coverage flag being the easiest way to turn that on, and codecov simply processes those reports and persists them online.

I was assuming the --coverage flag is what was causing the coverage report to be printed in the Travis build. Which it is, but it is also why that information is being collected in the first place. It looks like you can collect without reporting, but all those ways introduce complexity, so I am fine with the extra info in the build.

My preference would be for PR #632, but this one is fine too.

@MichaelDimmitt
Copy link
Collaborator Author

MichaelDimmitt commented Jul 6, 2018

@wacii, I too am a fan of #632,

FYI, when a test fails in react-scripts test -- --coverage
An npm error triggers. This does not break any functionality for the application or Travic CI

Wanted to give a headsup. In case someone uses the coverage command for a failing test suite.

Added documentation to the project, here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants