react-native-mock: TypeError: Cannot read property 'number' of undefined
I have an error with all my Views components
FAIL __tests__/components/Login.spec.js
● Test suite failed to run
TypeError: Cannot read property 'number' of undefined
at Object.<anonymous> (node_modules/react-native-mock/build/propTypes/LayoutPropTypes.js:21:37)
at Object.<anonymous> (node_modules/react-native-mock/build/propTypes/ViewStylePropTypes.js:6:22)
at Object.<anonymous> (node_modules/react-native-mock/build/components/View.js:6:25)
My deps:
"dependencies": {
"react": "^16.0.0-alpha.13",
"react-native": "^0.45.1",
"react-native-image-picker": "0.26.3",
"react-native-linear-gradient": "2.0.0",
"react-native-material-textfield": "0.6.0",
"react-native-mock": "^0.3.1",
"react-native-scrollable-tab-view": "0.6.6",
"react-native-snackbar": "0.3.6",
"react-native-vector-icons": "4.2.0",
"react-navigation": "1.0.0-beta.11",
"react-redux": "5.0.5",
"redux-saga": "0.15.3",
"styled-components": "^2.1.0"
},
"devDependencies": {
"babel-jest": "20.0.0",
"babel-preset-react-native": "1.9.2",
"chai": "4.0.2",
"chai-as-promised": "7.0.0",
"colors": "1.1.2",
"cors": "2.8.3",
"cucumber": "2.0.0-rc.9",
"debug": "2.6.8",
"express": "4.15.3",
"jest": "20.0.0",
"lodash": "4.17.4",
"react-test-renderer": "16.0.0-alpha.6",
"redux": "3.6.0",
"standard": "10.0.2",
"wd": "1.2.0"
},
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 50
- Comments: 23 (2 by maintainers)
Any updated here?
Any expectations when it will be fixed?
Any updates on this?
According to me it is because the package still imports the propTypes from react. It should use the package
prop-typesto get the propTypes.I have a pull request that fixes this https://github.com/RealOrangeOne/react-native-mock/pull/158
Once you have the updated package, you’ll need to go into node_modules/react-native-mock and run
npm run buildbefore it will compile.Has anyone figured out a way around this besides downgrading react/react-native?
you miss import PropTypes from ‘prop-types’;
I haven’t encountered that, sorry. I’m away from my laptop on leave for two weeks so will have to have a look at it then. Hopefully the rewrite branch is ready by then anyway
@RealOrangeOne Any fix for this issue ? Im using latest RN v51 & React 16.
Documentation on support is unfortunately kinda lacking.
I dont have support for any version of
jest, as it has a builtin mock ofreact-native, however there’s theoretically nothing stopping it working. The latest version ofreact-nativei’ve tested this on is0.42, however i’m planning to add better support for current a newer versions soon