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

Fix tests to cover uncovered branches #26

Merged
merged 1 commit into from
Jan 16, 2024
Merged

Conversation

mbland
Copy link
Owner

@mbland mbland commented Jan 16, 2024

This commit solves the coverage drop from:

Restores istanbul as the coverage reporter for the JSDom-based CI run to restore consistency in reporting, particularly in Coveralls.


Adapted from the new test/missing-app-div/jsdom.test.js:

Moved the "missing #app div" test into a separate directory from the other tests in ../jsdom.test.js. to prevent Node.js from using the same test-modules/main.js import. Otherwise:

  • If the test case were in the same file, the "missing #app div" branch wouldn't execute and the test would fail.

  • If this test file were in the same directory, the Istanbul coverage reporter wouldn't see the coverage from the "missing #app div" branch. I don't know exactly why that is.

At the same time, the previous src="./main.js?version=missing" query suffix is no longer necessary.

I got the idea to organize the tests this way after successfully covering similar code in:

This commit solves the coverage drop from:

- #23
  01a79f6

Restores `istanbul` as the coverage reporter for the JSDom-based CI run
to restore consistency in reporting, particularly in Coveralls.

---

Adapted from the new test/missing-app-div/jsdom.test.js:

Moved the "missing #app div" test into a separate directory from the
other tests in ../jsdom.test.js. to prevent Node.js from using the same
`test-modules/main.js` import. Otherwise:

- If the test case were in the same file, the "missing #app div" branch
  wouldn't execute and the test would fail.

- If this test file were in the same directory, the Istanbul coverage
  reporter wouldn't see the coverage from the "missing #app div" branch.
  I don't know exactly why that is.

At the same time, the previous `src="./main.js?version=missing"` query
suffix is no longer necessary.

I got the idea to organize the tests this way after successfully
covering similar code in:

- mbland/tomcat-servlet-testing-example#85
  mbland/tomcat-servlet-testing-example@b5df30e
@mbland mbland self-assigned this Jan 16, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 7548603948

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 100.0%

Totals Coverage Status
Change from base Build 7548004478: 0.6%
Covered Lines: 79
Relevant Lines: 79

💛 - Coveralls

@mbland mbland merged commit 4cc6878 into main Jan 16, 2024
3 checks passed
@mbland mbland deleted the improve-test-coverage branch January 16, 2024 23:06
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.

2 participants