Skip to content

chore: Fix useMobile tests#191

Merged
jperals merged 1 commit intomainfrom
fix/use-mobile-tests
Feb 3, 2026
Merged

chore: Fix useMobile tests#191
jperals merged 1 commit intomainfrom
fix/use-mobile-tests

Conversation

@jperals
Copy link
Member

@jperals jperals commented Feb 2, 2026

These tests were failing, but they were not run because the folder name was wrong (_tests__ instead of __tests__).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.90%. Comparing base (97a9ccb) to head (62122fe).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
- Coverage   99.05%   98.90%   -0.16%     
==========================================
  Files          42       44       +2     
  Lines        1165     1185      +20     
  Branches      316      318       +2     
==========================================
+ Hits         1154     1172      +18     
- Misses         10       12       +2     
  Partials        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.

act(() => {
Object.defineProperty(window, 'innerWidth', { value: width });
// Mock safeMatchMedia to return the result of a passed-in `max-width` query based on the width the window wasjust resized to
jest.spyOn(safeMatchMediaModule, 'safeMatchMedia').mockImplementation((element, query) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

The test code was copied over from the components package, but here it didn't work because the implementation of getIsMobile behaves differenttly in one package vs the other when window.matchMedia is not present:

Fallbacks are not needed because matchMedia has very good browser support: https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia#browser_compatibility

@jperals jperals marked this pull request as ready for review February 2, 2026 18:15
@jperals jperals requested a review from a team as a code owner February 2, 2026 18:15
@jperals jperals requested review from pan-kot and taheramr and removed request for a team February 2, 2026 18:15
@jperals jperals added this pull request to the merge queue Feb 3, 2026
Merged via the queue into main with commit 93d2336 Feb 3, 2026
43 checks passed
@jperals jperals deleted the fix/use-mobile-tests branch February 3, 2026 09:42
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

Comments