Unit tests fail when adding MantineProvider #6757
Replies: 2 comments 1 reply
-
You can find a fully working example in this repository – https://github.com/mantinedev/vite-template |
Beta Was this translation helpful? Give feedback.
-
Short Answer: I was facing the exact same issue. Then, I found the issue in my case. Be careful about your components which are using browser's utilities. Because there is not any browser utility while unit testing with vite or jest. Long answer: I followed all of the guides but I had this issue too. Even, I created fresh project with vite template provided in the docs, but still got same issue. Then I realized..
in my case, the error line showed useOpenStickerSet.ts was the issue and it was right. I was writing integration tests for whole page which includes many components under the hood. And one of them is using this hook. The hook is using some other functions or sub-hooks which are using some browser utilities like localStorage or resize. After I mocked this "useOpenStickerSet" hook, my problem's solved. |
Beta Was this translation helpful? Give feedback.
-
Dependencies check up
What version of @mantine/* packages do you have in package.json?
7.12.2
What package has an issue?
@mantine/core
What framework do you use?
Vite
In which browsers you can reproduce the issue?
None
Describe the bug
I'm trying to run some unit tests using Vitest. I've followed the docs, and I've looked at the template, however I keep getting this error:
Error: createRoot(...): Target container is not a DOM element.
This happens whenever I try to add to my custom render function.
If possible, include a link to a codesandbox with a minimal reproduction
No response
Possible fix
No response
Self-service
Beta Was this translation helpful? Give feedback.
All reactions