picker
picker copied to clipboard
Jest setup
Hi ! Are there any guides about how to setup this with jest ? A simple example with Picker causes the following error:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `Picker`.
I figured this happens because in my setup file, I mock the platform (for other tests purposes):
jest.mock('react-native/Libraries/Utilities/Platform', () => {
const platform = jest.requireActual('react-native/Libraries/Utilities/Platform')
return {
...platform,
OS: 'android',
constants: {
...platform.constants,
reactNativeVersion: {
major: 0,
minor: 70,
patch: 6
}
}
}
})
Any ideas ?
EDIT:
I had to put Platform.OS = 'ios' before the render in my test file for this to work.
Still means there's an issue with Platform=android & jest :/
same here testing simulating android platform 😢
Same issue on android platform