Skip to content

chore(web): Add option to create test coverage report file#10124

Merged
ermshiperete merged 2 commits intomasterfrom
chore/web/coverage
Dec 4, 2023
Merged

chore(web): Add option to create test coverage report file#10124
ermshiperete merged 2 commits intomasterfrom
chore/web/coverage

Conversation

@ermshiperete
Copy link
Copy Markdown
Contributor

This adds a coverage parameter to web/build.sh that will create a coverage report in HTML format in web/build/coverage/index.html.

@keymanapp-test-bot skip

This adds a `coverage` parameter to `web/build.sh` that will create
a coverage report in HTML format in `web/build/coverage/index.html`.
@keymanapp-test-bot keymanapp-test-bot bot added this to the A17S27 milestone Dec 1, 2023
Copy link
Copy Markdown
Contributor

@jahorton jahorton left a comment

Choose a reason for hiding this comment

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

It's worth noting that use of c8 for coverage will, at present, only report coverage for parts that are testable headlessly - I don't think c8 will "kick in" during karma-based unit (web/src/test/auto/dom) or integrated (web/src/test/auto/integrated) tests. If you want to double-check that, post a copy or a screenshot of the reports you're currently getting as output; I should be able to tell pretty quickly.

If my intuition here is correct, the coverage reports may feel a bit 'lacking' in that regard - lots of KeymanWeb's code at this level is DOM-dependent. I did look around a bit for anything simple that might be viable, but the simplest thing I've found is this: https://webreflection.medium.com/js-on-dom-code-coverage-bb1f9011780f

There's a fair bit of work involved, and the direction I got at the time was that doing code-coverage for KeymanWeb was too low a priority. Granted, that was before the gesture work and ES module work was completed, so maybe it's different now.

"configure" \
"build" \
"test" \
"coverage Create an HTML page with code coverage" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just noticed - this is only in build.sh, with no equivalent in test.sh?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, I thought it's sufficient to have it in the top-level build.sh

@jahorton
Copy link
Copy Markdown
Contributor

jahorton commented Dec 4, 2023

OK, so running it locally, I get...

image

Looks like it just collates the different coverage reports across all subcomponents (filtered based on Web's .c8rc.json's src property) with a top-level summary for each code folder that is tested, leaving out information about anything that isn't coverage-tested headlessly. In particular, note that there's nothing in the report corresponding to web/src/app/browser, web/src/engine/attachment, etc. The DOM components may as well not exist as far as the report is concerned.

The lack of anything regarding DOM-based components isn't completely ideal... but is probably better than falsely claiming 0% coverage for them.

Gesture stuff shows up in the report since I didn't do a repo-wide clean; its coverage stuff was still lingering around and possible for the coverage collator to pick up.

Co-authored-by: Marc Durdin <marc@durdin.net>
@ermshiperete
Copy link
Copy Markdown
Contributor Author

I agree - it's not ideal that we don't show coverage for all code, but it's a start that we can improve over time.

@ermshiperete ermshiperete merged commit d4fcc8f into master Dec 4, 2023
@ermshiperete ermshiperete deleted the chore/web/coverage branch December 4, 2023 10:25
@keyman-server
Copy link
Copy Markdown
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.223-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants