Open jamesmcn1 opened 5 years ago
@jamesmcn1 you resolve this?!
Hi @lucianomlima - not yet but we've just upgraded to RN 0.62.2 so maybe this will fix this. Test has been commented out for now.
I get this error when I run my simple render component test
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
This is due to the {source} object. @jamesmcn1 any update?
Nope, haven't managed to fix this - the test still remains commented out. Output of console.log(rendered.debug()) is still:
<View testID="ResourcesItemScreen" style={{...}}>
<[object Object] source={{...}} style={{...}} activityIndicator={{...}} onError={[Function]} />
</View>
RN Version : "react-native": "0.63.2"
Issue: With same issue on this. Weird the output with object. <[object Object] source={{...}} page={1} style={{...}} />
console error: Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
I look forward to hearing on this. Thanks!
From the https://reactnative.dev/docs/testing-overview ,
Component tests are only JavaScript tests running in Node.js environment. They do not take into account any iOS, Android, or other platform code which is backing the React Native components. It follows that they cannot give you a 100% confidence that everything works for the user. If there is a bug in the iOS or Android code, they will not find it.
Any update on this?
solved this issue with this
jest.mock('react-native-pdf'); jest.mock('react-native-blob-util', () => { return { Share: () => ({ DocumentDir: jest.fn().mockImplementation(() => Promise.resolve()), }), }; });
What
react-native
version are you using?0.57.8
Whatreact-native-pdf
version are you using?5.0.12
What platform does your issue occur on? (android/ios/both) N/ATrying to test via Jest to ensure Pdf component renders on page, but React.createElement is failing resulting in it not being rendered by shallow.
Component:
Test:
Output of console.log(rendered.debug()):
Console warning:
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Looks like it's an issue with the way Pdf is being imported in component. When I try:
import { Pdf } from 'react-native-pdf';
I getWarning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Anyone able to assist? Thanks :)