IjzerenHein / IjzerenHein/react-navigation-shared-element
Jest Mocking
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
I'm getting `TypeError: (0 , _reactNavigationSharedElement.createSharedElementStackNavigator) is not a function`
when testing with jest `yarn test` or `npm jest`
I have added these mocks to jest Setup file
```javascript
jest.mock('react-native-shared-element', () => {
return () => ({});
});
jest.mock('react-navigation-shared-element', () => {
return () => ({
createSharedElementStackNavigator: jest.fn(),
});
});
```
But still failing to test with Jest
I'm using
"react-native": "0.64.0",
"jest": "^25.1.0",
"react-native-shared-element": "^0.7.0",
"react-navigation-shared-element": "3.0.0",
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Jest setup file and the shown mocks, then run `yarn test` or `npm jest` to reproduce the reported TypeError. Compare the mocked `react-navigation-shared-element` export with the failing `createSharedElementStackNavigator` call; done means the Jest tests no longer fail with this error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100