I'm testing a React Native app build with Typescript.
Jest Output:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
Ps. Rn work anyway also render method, but i don't understand where is this bug in the code. Anyone can help me?
App.test.tsx
import 'react-native';
import * as React from 'react';
import App from '../App';
import renderer from 'react-test-renderer';
it('renders correctly', () => {
renderer.create(<App />);
});
Found the solution here: Why is my jest test failing in React native with typescript?
If you are using react-native with expo, add this to your package.json:
"jest": {
"preset": "jest-expo",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
]
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With