RealOrangeOne / react-native-mock

A fully mocked and test-friendly version of react native (maintainers wanted)
MIT License
570 stars 153 forks source link

Create ViewPropTypes #140

Closed newtonry closed 7 years ago

newtonry commented 7 years ago

Due to the deprecation of View.propTypes, we are now supposed to use ViewPropTypes imported from react-native. This library doesn't support that yet, so this PR adds ViewPropTypes. It should resolve issues like https://github.com/RealOrangeOne/react-native-mock/issues/139 and https://github.com/RealOrangeOne/react-native-mock/issues/132. In it, I've:

jcharlet commented 7 years ago

Hi guys, sorry for the newbie question but how to load the master branch of react-native-mock in my project?

I tried

npm install --save github:RealOrangeOne/react-native-mock#master
cd nodes_modules/react-native-mock
npm install
rm -rf nodes_modules

but it must be wrong because I get this issue after:

● Test suite failed to run

TypeError: Cannot read property 'shape' of undefined

  at Object.<anonymous> (node_modules/react-native-mock/build/propTypes/EdgeInsetsPropType.js:8:33)
  at Object.<anonymous> (node_modules/react-native-mock/build/propTypes/ViewPropTypes.js:6:25)
  at Object.<anonymous> (node_modules/react-native-mock/build/components/View.js:7:20)

Thanks!

newtonry commented 7 years ago

@jcharlet if I understand correctly you shouldn't be rm -rf nodes_modules in the nodes_modules/react-native-mock directory. Those are the dependencies that react-native-mock has. By deleting them, React(https://github.com/RealOrangeOne/react-native-mock/blob/master/src/propTypes/EdgeInsetsPropType.js#L4) is probably becoming undefined and hence, PropTypes.shape will not work.

Try it again without deleting the node_modules directory after installing the modules.

jcharlet commented 7 years ago

@newtonry great thanks! I had conflicts between react-native module of my project and react-native-mock (they use different versions). so I simply removed react-native from react-native-mock/node_modules (but still kept the rest) and it now works :) !

gardner commented 7 years ago

I am running into issues with this PR as well.

After running: npm install --save-dev github:RealOrangeOne/react-native-mock#master

Then npm run ava

Looks like the package.json and mock.js expect a file to be present: Error: Cannot find module './build/react-native'

$ grep -H build/react-native node_modules/react-native-mock/*
node_modules/react-native-mock/mock.js:const ReactNativeMock = require('./build/react-native');
node_modules/react-native-mock/package.json:  "main": "build/react-native.js",

but there is no build/ directory relative to the files:

$ls node_modules/react-native-mock
LICENSE      README.md    mock.js      package.json src
lucascarvalho commented 7 years ago

@gardner same problem here, did you find a solution for this?

khirakawa commented 6 years ago

@gardner @lucascarvalho You need to build react-native-mock if you install it via npm install --save-dev github:RealOrangeOne/react-native-mock#master

  1. cd node_modules/react-native-mock

  2. Add the following to package.json

    "babel": {
    "presets": [
      "airbnb",
      "react-native"
    ]
    },
  3. Run npm run build