-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect "HappyDOM" in userAgent string in same way as "jsdom" #10374
Comments
FYI for anyone else using vitest+happy-dom: If you are using version > 12 of happy-dom, a workaround is to add the following to your defineConfig:
|
I wonder if we can use the But to be fair, I'm not even sure if this error is still necessary, as it seems like the grid works just fine if the parent doesn't have predefined dimensions set: https://codesandbox.io/s/amazing-nightingale-yl7c8s?file=/Demo.tsx @mui/xgrid What do you think? |
I did a |
This change enables testing with Happy DOM without annoying warnings popping up. Fixes mui#10374.
This change enables testing with Happy DOM without annoying warnings popping up. Fixes mui#10374.
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @anthonyblond How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Duplicates
Latest version
Summary 💡
Summary
Wherever there is code like
const isJSDOM = /jsdom/.test(window.navigator.userAgent);
, generalise it to use the/jsdom|HappyDOM/
instead.Detail
Currently there are several places in the code that have logic like the following (copied from
packages/grid/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts
):This relies on the jsdom testing environment using "Mozilla/5.0 (linux) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/{packageVersion}" as its default userAgent string.
If using vitest with the default environment of happy-dom, instead, this won't work and the error is shown in tests.
release v12.0.0.0 of happy-dom has fixed an issue with its useragent string, and now uses "Mozilla/5.0 (X11; {process.platform} {process.arch}) AppleWebKit/537.36 (KHTML, like Gecko) HappyDOM/{packageVersion}" as its default. So changing the regex to
/jsdom|HappyDOM/
should be sufficient.Examples 🌈
No response
Motivation 🔦
Make development of apps using mui-x (specifically in my case x-data-grid) with vite easier without workarounds.
I was going to just submit a simple PR specifically for
useGridDimensions.ts
in x-data-grid, but realised the same logic is used all across the library, so there might be a different pattern that needs to be implemented.Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: