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

Help wanted to reach ~100% code coverage #1404

Closed
paulmelnikow opened this issue Jan 29, 2019 · 21 comments
Closed

Help wanted to reach ~100% code coverage #1404

paulmelnikow opened this issue Jan 29, 2019 · 21 comments
Labels

Comments

@paulmelnikow
Copy link
Member

paulmelnikow commented Jan 29, 2019

As discussed in #1374 and elsewhere, our current milestone is to reach close to 100% coverage on the beta branch. With 100% test coverage, the tests take on a life of their own in maintaining the project, and will allow us to refactor – and add functionality – with confidence.

@jlilja, @gr2m and I conducted a line-by-line triage and added 46 comments marked TODO-coverage in #1375 and #1380. These are all the spots in the code where work on this milestone is needed.

As of right now we're down to 40, so we're 13% of the way there!

You can help!

  1. Look in the beta branch for TODO-coverage.
  2. Pick a todo or a file to start working on.
  3. Post here, so we don't duplicate any work.
  4. When you're ready, open your pull request on the beta branch.

One bit of guidance: our test strategy is to avoid narrow-bracket tests, and instead aim to keep writing high-level functional tests (i.e. via calls to nock()). If there is not a way to exercise the code through the public nock API, it may be dead code. In the case of dead code, it's better to remove it than to add tests.

@paulmelnikow
Copy link
Member Author

I'm going to work on the coverage TODOs in request_overrider.js.

I am no longer working in this file. I got through a lot of the header code, which is what prompted the umbrella TODO-coverage comment we wrote at the top of the file. The file is less of a mystery now. Though there are a smattering of uncovered lines for various edge cases. It may need another round of triage.

@paulmelnikow
Copy link
Member Author

paulmelnikow commented Jan 29, 2019

I just tackled the last one in lib/common.js. I'll open another PR in a moment for the truthiness checks on http.ClientMessage and http.OutgoingMessage in lib/intercept.js.

@paulmelnikow
Copy link
Member Author

@gr2m Do you want to finish the one in socket.js?

#1374 (comment)

@gr2m
Copy link
Member

gr2m commented Feb 3, 2019

Please take it if you can, I won’t get to it before our vacation next week

@paulmelnikow
Copy link
Member Author

paulmelnikow commented Feb 3, 2019

After the open PRs are merged, these are the coverage TODOs that are left:

lib/common.js:      // TODO-coverage: `override` is always truthy. Refactor to eliminate the
lib/common.js:  // TODO-coverage: Add a test to cover the missing condition, or remove if
lib/common.js:  // TODO-coverage: Add a test to cover the missing condition, or remove if
lib/common.js:    // TODO-coverage: Add a test to cover the missing condition, or remove if
lib/common.js:    // TODO-coverage: For `_.isObject(headers)`, add a test to cover the
lib/common.js:  // TODO-coverage: either replace this with a library function or add a
lib/common.js:  // TODO-coverage: Find out what's not covered. Probably refactor code to
lib/interceptor.js:  // TODO-coverage: This looks very special. Worth an investigation.
lib/recorder.js:      // TODO-coverage: Try to add a test for this case. If we can't figure
lib/recorder.js:  // TODO-coverage: Try to add coverage of this case.
lib/recorder.js:    // TODO-coverage: Try to add coverage of this case.
lib/recorder.js:      // TODO-coverage: Investigate why this was added. Add a test if
lib/recorder.js:      // TODO-coverage: Investigate why this was added. Add a test if
lib/recorder.js:          // TODO-coverage: The `else` case is missing coverage. Maybe look
lib/recorder.js:              // TODO-coverage: This is missing coverage. Could this be
lib/recorder.js:      // TODO-coverage: Is this for parity with native node `req.write()`? If
lib/recorder.js:          // TODO-coverage: Add a test.
lib/request_overrider.js:// TODO-coverage: This file is puzzling. It would be good to investigate why
lib/scope.js:      // TODO-coverage: Try to find an actual use case where a non-string
lib/scope.js:    // TODO-coverage: `else` throw with an error.
lib/scope.js:    // TODO-coverage: Find out what `body === '*'` means. Add a comment here

That's 54% of the way done! I may pick up one or two of these, though TBH I've gone about as far as I want to with this. If anyone else is interested in working on these, help would be really appreciated! They tend to be good puzzles!

@RichardLitt
Copy link
Member

Thank you so much, @paulmelnikow! I'll grab a couple. Perhaps we should schedule another open source friday hackathon, too?

@paulmelnikow
Copy link
Member Author

That sounds good!

gr2m pushed a commit that referenced this issue Sep 4, 2019
For #1404 (code coverage)

We were doing this logic in several places and not always getting good
coverage. Adds a small utility DRY things up.
gr2m pushed a commit that referenced this issue Sep 4, 2019
For #1404

Add tests for the success, reject, and ignore cases.
gr2m pushed a commit that referenced this issue Sep 4, 2019
For #1404 

* test(socket): add coverage for timeout without a callback
gr2m pushed a commit that referenced this issue Sep 4, 2019
We've hit 100% coverage!

Coveralls is mostly useful for growing coverage over time. I think the text report is adequate for finding gaps in feature branches and preventing us from slipping. I don't think it's worth running Coveralls anymore.

I replaced the coverage badge with a static one!

Closes #1404
gr2m pushed a commit that referenced this issue Sep 4, 2019
gr2m pushed a commit that referenced this issue Sep 4, 2019
Unable to find a way to trigger the conditionals. See #1404 for reasoning why I took on this test.
gr2m pushed a commit that referenced this issue Sep 4, 2019
I worked on this file quite a bit since this comment was written. At this point the remaining work can be broken out into separate, manageable-seeming todos.

Ref #1404
gr2m pushed a commit that referenced this issue Sep 4, 2019
Ref #1404 (comment)

This leaves intact two missed coverage spots in `lib/recorder.js` which are being taken care of in #1588.

Also ref #1607
gr2m pushed a commit that referenced this issue Sep 4, 2019
* refactor(common): replace lodash.forOwn with Array.reduce

This commit replaces usage of lodash.forOwn with a combination of Object.keys() & Array.reduce.

Related #1285

* refactor(commong): use Array.map

This commit simplifies array formatting by using Array.map instead of a plain for loop.

* test(common): add unit test coverage for #formatQueryValue

This commit adds unit test coverage for #formatQueryValue.

Related #1404

* chore: run prettier to fix lint errors

* fix: use Object.entries() in favor of Object.keys()

This commit replaces the usage of Object.keys() with Object.entries() to address [this](#1598 (comment)) comment.

* test(common): break down tests

This commit addresses the following comments:
1- #1598 (comment)
2- #1598 (comment)

* chore: run prettier to fix lint errors

* refactor(common): replace lodash.forOwn with Array.reduce

This commit replaces usage of lodash.forOwn with a combination of Object.keys() & Array.reduce.

Related #1285

* refactor(commong): use Array.map

This commit simplifies array formatting by using Array.map instead of a plain for loop.

* test(common): add unit test coverage for #formatQueryValue

This commit adds unit test coverage for #formatQueryValue.

Related #1404

* chore: run prettier to fix lint errors

* fix: use Object.entries() in favor of Object.keys()

This commit replaces the usage of Object.keys() with Object.entries() to address [this](#1598 (comment)) comment.

* test(common): break down tests

This commit addresses the following comments:
1- #1598 (comment)
2- #1598 (comment)

* chore: run prettier to fix lint errors

* chore: remove unnecessary formatting changes
gr2m pushed a commit that referenced this issue Sep 4, 2019
For #1404 (code coverage)

We were doing this logic in several places and not always getting good
coverage. Adds a small utility DRY things up.
gr2m pushed a commit that referenced this issue Sep 4, 2019
For #1404

Add tests for the success, reject, and ignore cases.
gr2m pushed a commit that referenced this issue Sep 4, 2019
For #1404 

* test(socket): add coverage for timeout without a callback
gr2m pushed a commit that referenced this issue Sep 4, 2019
We've hit 100% coverage!

Coveralls is mostly useful for growing coverage over time. I think the text report is adequate for finding gaps in feature branches and preventing us from slipping. I don't think it's worth running Coveralls anymore.

I replaced the coverage badge with a static one!

Closes #1404
gr2m pushed a commit that referenced this issue Sep 5, 2019
gr2m pushed a commit that referenced this issue Sep 5, 2019
Unable to find a way to trigger the conditionals. See #1404 for reasoning why I took on this test.
gr2m pushed a commit that referenced this issue Sep 5, 2019
I worked on this file quite a bit since this comment was written. At this point the remaining work can be broken out into separate, manageable-seeming todos.

Ref #1404
gr2m pushed a commit that referenced this issue Sep 5, 2019
Ref #1404 (comment)

This leaves intact two missed coverage spots in `lib/recorder.js` which are being taken care of in #1588.

Also ref #1607
gr2m pushed a commit that referenced this issue Sep 5, 2019
* refactor(common): replace lodash.forOwn with Array.reduce

This commit replaces usage of lodash.forOwn with a combination of Object.keys() & Array.reduce.

Related #1285

* refactor(commong): use Array.map

This commit simplifies array formatting by using Array.map instead of a plain for loop.

* test(common): add unit test coverage for #formatQueryValue

This commit adds unit test coverage for #formatQueryValue.

Related #1404

* chore: run prettier to fix lint errors

* fix: use Object.entries() in favor of Object.keys()

This commit replaces the usage of Object.keys() with Object.entries() to address [this](#1598 (comment)) comment.

* test(common): break down tests

This commit addresses the following comments:
1- #1598 (comment)
2- #1598 (comment)

* chore: run prettier to fix lint errors

* refactor(common): replace lodash.forOwn with Array.reduce

This commit replaces usage of lodash.forOwn with a combination of Object.keys() & Array.reduce.

Related #1285

* refactor(commong): use Array.map

This commit simplifies array formatting by using Array.map instead of a plain for loop.

* test(common): add unit test coverage for #formatQueryValue

This commit adds unit test coverage for #formatQueryValue.

Related #1404

* chore: run prettier to fix lint errors

* fix: use Object.entries() in favor of Object.keys()

This commit replaces the usage of Object.keys() with Object.entries() to address [this](#1598 (comment)) comment.

* test(common): break down tests

This commit addresses the following comments:
1- #1598 (comment)
2- #1598 (comment)

* chore: run prettier to fix lint errors

* chore: remove unnecessary formatting changes
gr2m pushed a commit that referenced this issue Sep 5, 2019
For #1404 (code coverage)

We were doing this logic in several places and not always getting good
coverage. Adds a small utility DRY things up.
gr2m pushed a commit that referenced this issue Sep 5, 2019
For #1404

Add tests for the success, reject, and ignore cases.
gr2m pushed a commit that referenced this issue Sep 5, 2019
For #1404

* test(socket): add coverage for timeout without a callback
gr2m pushed a commit that referenced this issue Sep 5, 2019
We've hit 100% coverage!

Coveralls is mostly useful for growing coverage over time. I think the text report is adequate for finding gaps in feature branches and preventing us from slipping. I don't think it's worth running Coveralls anymore.

I replaced the coverage badge with a static one!

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

No branches or pull requests

5 participants