Getting this error with running jest test. Have tried a lot to disable prop types rule:
Warning: Failed prop type: Invalid prop `source` supplied to `Image`, expected one of type [number].
in Image (at Welcome.js:134)
in Welcome (created by Connect(Welcome))
in Connect(Welcome) (at Welcome.test.js:25)
in Provider (at Welcome.test.js:24)
132 | {!global.isFirstTime &&
133 | <TouchableOpacity style={styles.backIcon} onPress={() => props.navigation.goBack()}>
> 134 | <Image source={Images.back} />
| ^
135 | </TouchableOpacity>
136 | }
137 |
Already added the rule in .eslintrc.json
"rules": {
"react/prop-types": 0
}
Also adding jest config moduleNameMapper
moduleNameMapper: {
'\\.(css|less)$': 'identity-obj-proxy',
'^(.+)\\.(jpg|jpeg|gif|png|mp4|mkv|avi|webm|swf|wav|mid)$': 'jest-static-stubs/$2'
},
So when the test runs Images.back contains:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==
- "react": "16.13.1",
- "react-native": "0.63.5 ",
- "eslint": "^8.39.0",
- "jest": "26.6.3",
Thanks.