Skip to content

Conversation

@shawnbot
Copy link
Contributor

@shawnbot shawnbot commented Jul 2, 2018

This adds the collectCoverage option to the jest field in package.json, which tells it to collect test coverage stats. By default, Jest generates a report on stdout upon completion, which I'd like to see on Travis before moving forward with trying to improve coverage in a separate PR to eventually do #90.

What is code coverage? It's really just a measure of how many lines and/or statements of your code are "touched" (run) by your test suite. For instance, if one of our components did something different when props.foo === "bar" and our tests never pass foo="bar", then the statements in that branching condition will be subtracted from the total. So if we had 100 statements and there were two in that if statement, our coverage could never exceed 98% until we added tests for that condition.

Side note: having configured projects to use Coveralls and CodeCov, it's so refreshing to have coverage built into Jest and be able to generate a report by just adding a flag to the configuration. We can even configure it to fail our CI builds if coverage drops below a threshold, either overall or on a per-file basis! ✨

This PR also includes a fix for #97 and a new section in the README about code coverage.

@shawnbot shawnbot requested a review from a team July 2, 2018 21:20
@shawnbot shawnbot changed the base branch from master to release-0.0.7-beta July 2, 2018 21:20
@shawnbot
Copy link
Contributor Author

shawnbot commented Jul 2, 2018

Hey, not bad: We've got almost 98% statement coverage! Check out this report:

File               |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
-------------------|----------|----------|----------|----------|-------------------|
All files          |     97.8 |    85.15 |    97.73 |    97.66 |                   |
 src               |    97.77 |    84.85 |    97.62 |    97.62 |                   |
  Avatar.js        |      100 |      100 |      100 |      100 |                   |
  Block.js         |      100 |    90.48 |      100 |      100 |             18,37 |
  Box.js           |      100 |      100 |      100 |      100 |                   |
  Button.js        |      100 |      100 |      100 |      100 |                   |
  ButtonDanger.js  |      100 |      100 |      100 |      100 |                   |
  ButtonLink.js    |      100 |      100 |      100 |      100 |                   |
  ButtonOutline.js |      100 |      100 |      100 |      100 |                   |
  Caret.js         |      100 |       75 |      100 |      100 |            30,132 |
  Details.js       |       75 |       60 |       80 |    72.73 |          17,18,20 |
  DonutChart.js    |      100 |      100 |      100 |      100 |                   |
  DonutSlice.js    |      100 |    66.67 |      100 |      100 |                17 |
  FlexContainer.js |      100 |      100 |      100 |      100 |                   |
  FlexItem.js      |      100 |      100 |      100 |      100 |                   |
  Heading.js       |      100 |      100 |      100 |      100 |                   |
  MergeStatus.js   |      100 |      100 |      100 |      100 |                   |
  StateLabel.js    |    95.24 |       90 |      100 |    95.24 |                32 |
  Text.js          |      100 |       60 |      100 |      100 | 21,27,29,30,31,32 |
  TextInput.js     |      100 |      100 |      100 |      100 |                   |
  props.js         |      100 |      100 |      100 |      100 |                   |
  theme.js         |      100 |      100 |      100 |      100 |                   |
 src/utils         |      100 |      100 |      100 |      100 |                   |
  testing.js       |      100 |      100 |      100 |      100 |                   |
-------------------|----------|----------|----------|----------|-------------------|

@shawnbot shawnbot mentioned this pull request Jul 2, 2018
Copy link

@emplums emplums left a comment

Choose a reason for hiding this comment

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

🙌 yay! I think this closes #97 too right?

@shawnbot shawnbot merged commit 93f718e into release-0.0.7-beta Jul 2, 2018
@shawnbot shawnbot deleted the test-coverage branch July 2, 2018 23:35
@shawnbot
Copy link
Contributor Author

shawnbot commented Jul 2, 2018

Yep, it should close automatically when we merge c04f816!

@emplums emplums mentioned this pull request Jul 3, 2018
6 tasks
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