Testing Mantine v6 Components with Jest in an Existing CRA App #6581
Unanswered
sohamkasar19
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm facing challenges while trying to add tests using Jest to my existing Create React App (CRA) project, which uses Mantine v6 components. I've been following the testing guidelines in the Mantine documentation and other online resources, but I'm still running into some issues.
Project Details:
Framework: Create React App
Mantine Version: v6.0.21
Testing Framework: Jest
Issue Description:
I've created a custom render function that wraps my components with MantineProvider to provide the Mantine theme and context. However, I'm encountering a recurring issue where the MantineProvider shows up as null or undefined in the logs, causing my tests to fail.
Steps I've Taken:
Code Snippets:
render.tsx :
Header.tsx :
Header.test.tsx :
Error message :
console.error
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
throw new Error('Element type is invalid: expected a string (for built-in ' + 'components) or a class/function (for composite components) ' + ("but got: " + (type == null ? type : typeof type) + "." + info));
^
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of
AllTheProviders
.Beta Was this translation helpful? Give feedback.
All reactions