Hi,
Iam unable to implement Jest with Typescript, it doesn’t look like Expo has sufficient documentation in this matter.
I tried to run a basic test in a new Bare typescript project and it fails but if I change to normal .Js file it works please help.
import React from 'react';
import { render } from '@testing-library/react-native';
import App from './App';
test('it renders all inputs as expected', () => {
const { toJSON } = render(<App />);
expect(toJSON()).toMatchSnapshot();
});
Error message:
console.error
Warning: React.createElement: type is invalid – expected a string (for built-in c
omponents) or a class/function (for composite components) but got: object.
5 |
6 | test('it renders all inputs as expected', () => {
> 7 | const { toJSON } = render(<App />);
| ^
8 |
9 | expect(toJSON()).toMatchSnapshot();
10 | });
Package.json
"devDependencies": {
"@babel/core": "^7.8.6",
"@testing-library/jest-native": "^3.4.2",
"@testing-library/react-native": "^7.0.2",
"@types/jest": "^26.0.13",
"@types/react": "~16.9.41",
"@types/react-native": "~0.62.13",
"@types/react-test-renderer": "^16.9.3",
"jest": "^26.4.2",
"jest-expo": "^38.0.2",
"jest-fetch-mock": "^3.0.3",
"react-test-renderer": "^16.13.1",
"ts-jest": "^26.3.0",
"typescript": "~3.9.5"
},
I look forward to your help.
Thank you