Change testing framework to vitest#152
Closed
hannessolo wants to merge 8 commits into
Closed
Conversation
hannessolo
marked this pull request as ready for review
July 11, 2025 15:52
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
==========================================
+ Coverage 75.61% 82.37% +6.76%
==========================================
Files 39 39
Lines 2243 1946 -297
Branches 0 332 +332
==========================================
- Hits 1696 1603 -93
+ Misses 547 342 -205
- Partials 0 1 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hannessolo
marked this pull request as draft
July 11, 2025 15:52
Contributor
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you look at codecov on main, you can see some nonsensical coverage (eg. lines switching from covered to uncovered where there isn’t even any control flow, or in the middle of comments).
Example: https://app.codecov.io/gh/adobe/da-admin/pull/154/blob/src/utils/auth.js?dropdown=coverage#L137
This seems to happen to modules which are being mocked by esmock somewhere in the codebase - commenting out the tests that mock those modules fixes it. So it seems that esmock is messing up the source mapping for c8.
Blocking issue
For some PRs, this isn’t a problem, eg. the recent PR GH-154 passes the codecov assessment, despite the coverage information being wrong in the changelist (see the changed file’s coverage here, obviously wrong: https://app.codecov.io/gh/adobe/da-admin/pull/154/blob/src/storage/utils/list.js#L28).
My PR got less lucky unfortunately: You can see it somehow decided a file in my changelist isn’t covered sufficiently and thus failed the PR check. This blocks the pagination changes.
Solution
My solution to this is to use vitest for both running tests and mocking, as it’s one of the only frameworks to support mocking es modules properly. PR here: #152
Once I switched to vitest, the coverage suddenly looks good on the PR that was previously failing: See here.