Increase code quality by increasing coverage: lib/report.js
Pull Request 452
This pull request has two commits.
Increase code quality by increasing coverage: lib/report.js
Expose the Report Class for future extension
Refactoring the report module export was necessary for testing
The purpose of this pull request is to increase code coverage for the file lib/report.js. This file was somewhat challenging, as certain line numbers were not covered only on certain versions of node.js. Furthermore, there were line numbers that were covered in other code coverage patches.
On Node.js versions 10.24.1 or 12.22.12 I was not able to get 100% coverage. On version 12.22.12 I was having some challenges getting this particular line covered by c8. It appears to be only a }, and the error is in branching. Version 10.24.1 seems to follow a different coverage model where reports vary greatly from other versions.
lib/report.js Code Coverage Matrix Report
| Test Type | File | Statement | Branch | Function | Lines | PASS |
|---|---|---|---|---|---|---|
| Final Test | lib/report.js | 100% | 100% | 100% | 100% | :heavy_check_mark: |
| Node 10.24.1 | lib/report.js | 90.58% | 80.39% | 86.66% | 90.58% | :x: |
| Node 12.22.12 | lib/report.js | 100% | 98.48% | 100% | 100% | :x: |
| Node 14.21.2 | lib/report.js | 100% | 100% | 100% | 100% | :heavy_check_mark: |
| Node 16.19.0 | lib/report.js | 100% | 100% | 100% | 100% | :heavy_check_mark: |
| Node 18.14.0 | lib/report.js | 100% | 100% | 100% | 100% | :heavy_check_mark: |
Following the Contributions Recommendations here.
- [x] Make sure you have installed the latest version of Node.js
- [x] Fork this project on GitHub and clone your fork locally
- [x] Create local branches to work within. These should also be created directly from the main branch. Local Fork here.
- [x] Make your changes.
- [x] Run tests to make sure all is okay (everything should pass except the snapshot).
- A complete log of initial test results.
- As instructed, ignore snapshot failures. 1 failing
- 54 passing in 28 seconds
- [x] Now update the snapshot.
- A complete log of snapshot test results.
- 55 passing in 28 seconds
- [x] If all is passing, commit your changes. Log of commit can be found here.
- [x] As a best practice, once you have committed your changes, it is a good idea to use git rebase (not git merge) to synchronize your work with the main repository.
- [x] Run tests again to make sure all is okay.
- A complete log of the final test results.
- 55 passing in 30 seconds
- [x] Push
- [x] Open the pull request, see details in the template.
- [ ] Make any necessary changes after review.
Unit Tests Results
| Test Type | PASS | Tests Passed | Tests Failed | Time |
|---|---|---|---|---|
| Initial Test | :x: | 54 passing | 1 failing | 28 seconds |
| Snapshot Test | :heavy_check_mark: | 55 passing | 0 failures | 28 seconds |
| Final Test | :heavy_check_mark: | 55 passing | 0 failures | 30 seconds |
Node Version Testing Matrix
| Node Version | PASS | Tests Passed | Tests Failed | Time |
|---|---|---|---|---|
| 10.24.1 | :heavy_check_mark: | 54 passing | 0 failures | 50 seconds |
| 12.22.12 | :heavy_check_mark: | 55 passing | 0 failures | 50 seconds |
| 14.21.2 | :heavy_check_mark: | 55 passing | 0 failures | 40 seconds |
| 16.19.0 | :heavy_check_mark: | 55 passing | 0 failures | 41 seconds |
| 18.14.0 | :heavy_check_mark: | 55 passing | 0 failures | 38 seconds |
Referencing Issue #448
I am working on some additional enhancements. I am not excited about how cumbersome chai-spies are, so I am researching other test investigation modules. Currently, there is only one line that is not getting covered in this current patch.