mantinedev / mantine

A fully featured React components library
https://mantine.dev
MIT License
27k stars 1.9k forks source link

Vitest unit test error: TypeError: Cannot read properties of undefined (reading 'matches') #7185

Closed iamdejan closed 4 days ago

iamdejan commented 4 days ago

Dependencies check up

What version of @mantine/* packages do you have in package.json?

7.14.3

What package has an issue?

@mantine/core

What framework do you use?

Vite

In which browsers you can reproduce the issue?

Not applicable – issue is not related to the browser

Describe the bug

I got this error log when I run my unit test (using vitest):

TypeError: Cannot read properties of undefined (reading 'matches')
    at setColorSchemeAttribute (file:///Users/macbook-giovannidejan/VSCodeProjects/iamdejan/react-iam-dashboard/node_modules/.pnpm/@mantine+core@file+..+mantine+packages+@mantine+core_@mantine+hooks@file+..+mantine+packages+_74wiwvogszovmx2h66rqol7oqu/node_modules/@mantine/core/src/core/MantineProvider/use-mantine-color-scheme/use-provider-color-scheme.ts:5:138)

Upon investigating with git bisect, I narrow down the bug to commit bad9bc5f0. I wonder if there's anything that triggers the error.

Thank you.

If possible, include a link to a codesandbox with a minimal reproduction

https://codesandbox.io/p/github/iamdejan/mantine-minimal-reproduction/main?import=true

Possible fix

No response

Self-service

rtivital commented 4 days ago

See https://mantine.dev/guides/vitest/#configuration