Skip to content

Change testing framework to vitest#152

Closed
hannessolo wants to merge 8 commits into
mainfrom
fix-mocks
Closed

Change testing framework to vitest#152
hannessolo wants to merge 8 commits into
mainfrom
fix-mocks

Conversation

@hannessolo

@hannessolo hannessolo commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

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.

@hannessolo
hannessolo marked this pull request as ready for review July 11, 2025 15:52
@codecov

codecov Bot commented Jul 11, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.37%. Comparing base (20b1a61) to head (ff6c5e9).
Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hannessolo
hannessolo marked this pull request as draft July 11, 2025 15:52
@hannessolo hannessolo closed this Jul 11, 2025
@hannessolo

hannessolo commented Jul 11, 2025

Copy link
Copy Markdown
Contributor Author
  • TODO: One test is currently commented out

@hannessolo hannessolo reopened this Jul 14, 2025
@hannessolo hannessolo closed this Jul 14, 2025
@hannessolo hannessolo reopened this Jul 14, 2025
@hannessolo
hannessolo marked this pull request as ready for review July 14, 2025 13:34
@hannessolo hannessolo closed this Jul 21, 2025
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.

1 participant