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
Increase code quality by increasing coverage: lib/report.js #452
base: main
Are you sure you want to change the base?
Conversation
b50322c
to
3611fb8
Compare
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452)
3611fb8
to
e21c26a
Compare
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452)
e21c26a
to
a75a8c7
Compare
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452)
a75a8c7
to
7b91bcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a note about testing "private" methods.
* the temporary directory | ||
* | ||
*/ | ||
it('cause Report._loadReports to throw an error and catch it', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are private methods, rather than forcing them to throw, it would be better if we could figure out a condition that caused loadReports
to throw an exception, when invoked through the public interface.
tldr; it's better if the tests describe an understandable beahviour, e.g., "when reports are in this format, an exception is thrown".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are private methods, rather than forcing them to throw, it would be better if we could figure out a condition that caused loadReports to throw an exception, when invoked through the public interface.
Conditions that would cause the exception to be thrown will be discovered over time through bug reports.
From my perspective, it can be difficult to tell what application state can cause bugs. That is why they are bugs. It's an application state that you didn't anticipate, and there is no logic written for that application state. In certain cases, it may be an invalid application state or at other times it could be a feature not working as intended. It's important to test that exceptions are thrown and working as expected, then as bugs arise, hopefully, it's covered by an exception.
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452) Expose the Report Class for future extension (bcoe#452) refactor: lib/report.js to expose the class Report (bcoe#452) refactor: lib/command/* and test/fixtures/report/* to import report constructor (bcoe#452)
b831662
to
546fd30
Compare
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452) Expose the Report Class for future extension (bcoe#452) refactor: lib/report.js to expose the class Report (bcoe#452) refactor: lib/command/* and test/fixtures/report/* to import report constructor (bcoe#452)
546fd30
to
351240c
Compare
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452) Expose the Report Class for future extension (bcoe#452) refactor: lib/report.js to expose the class Report (bcoe#452) refactor: lib/command/* and test/fixtures/report/* to import report constructor (bcoe#452)
351240c
to
aa14b3c
Compare
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452) Expose the Report Class for future extension (bcoe#452) refactor: lib/report.js to expose the class Report (bcoe#452) refactor: lib/command/* and test/fixtures/report/* to import report constructor (bcoe#452)
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452) Expose the Report Class for future extension (bcoe#452) refactor: lib/report.js to expose the class Report (bcoe#452) refactor: lib/command/* and test/fixtures/report/* to import report constructor (bcoe#452)
aa14b3c
to
a6962e1
Compare
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. |
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452) Expose the Report Class for future extension (bcoe#452) refactor: lib/report.js to expose the class Report (bcoe#452) refactor: lib/command/* and test/fixtures/report/* to import report constructor (bcoe#452)
6a6f0e7
to
5a812ff
Compare
refactor: refactor some of the functions in lib/report.js to target certain versions of node, to ignore certain lines by c8 for consideration of removal, and to increase code coverage (bcoe#452) test: Added two test cases in test/report.js to test error handling (bcoe#452) test: Added file test/report-mock.js to support test cases in test/report.js (bcoe#452) test: moved the fake-source-map.js test inside of a describe block. (bcoe#452) Expose the Report Class for future extension (bcoe#452) refactor: lib/report.js to expose the class Report (bcoe#452) refactor: lib/command/* and test/fixtures/report/* to import report constructor (bcoe#452)
5a812ff
to
12fd709
Compare
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
Following the Contributions Recommendations here.
Unit Tests Results
Node Version Testing Matrix
Referencing Issue #448