79668099

Date: 2025-06-16 19:02:37
Score: 0.5
Natty:
Report link

You're hitting a limitation of jsdom — it doesn't support CSS media queries or actual rendering. So even if you stub innerWidth, CSS like @media (min-width: 768px) won’t trigger.

To fix this:

vi.stubGlobal('matchmedia', query => ({
 matches: query.includes('min-width: 768px'),
 addListener: () => {},
 removeListener: () => {}
}));

Pure CSS based visibility be tested in Vitest/jsdom, it's not supported.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @media
  • Low reputation (0.5):
Posted by: Lucian Wu