react-navigation-shared-element
react-navigation-shared-element copied to clipboard
[Jest] Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function
I'm getting this error when I run tests
Warning: React.createElement: 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.
I'm using jest and RNTL. The line of the problem is when declare the SharedElement component:
<SharedElement id={`${id}${company?.logoUrl}`}>
Here my depedencies and devDependencies
"@apollo/client": "^3.3.18",
"react": "17.0.1",
"react-native": "0.64.1",
"react-native-shared-element": "^0.7.0",
"react-navigation-shared-element": "^5.0.0-alpha1",
},
"devDependencies": {
"@testing-library/react-hooks": "^7.0.0",
"@testing-library/react-native": "^7.2.0",
"babel-jest": "^26.6.3",
"jest": "^26.6.3",
"react-test-renderer": "17.0.1"
}
I also have mocked:
jest.mock('react-native-shared-element', () => {
return () => ({});
});
jest.mock('react-navigation-shared-element', () => {
return () => ({
createSharedElementStackNavigator: jest.fn(),
});
});
Did you find a solution?
I'm stuck with this too.
I haven't found a solution yet @giuseppeabn
Anyone find a solution?