RealOrangeOne / react-native-mock

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

Rewrite for RN 0.50+ #151

Closed jasonfma closed 6 years ago

jasonfma commented 6 years ago

Major upgrade that supports 0.50+

NOTE: This is a PR into the existing rewrite branch

jasonfma commented 6 years ago

Changing to support RN 0.50+ because the AndroidProgressBar had a breaking change in RN 0.49 that was fixed in RN 0.50. Rather than start off backwards compatible with 0.49, just do 0.50+.

jasonfma commented 6 years ago

Dropping support for Node 4. https://travis-ci.org/RealOrangeOne/react-native-mock/jobs/297785954

dusave commented 6 years ago

Should probably add react, react-dom, and react-native as dev dependencies also. When trying to build locally without those packages, it fails

RealOrangeOne commented 6 years ago

Initial skim looks good. Would probably be ideal to update the README stating that we've dropped support for Node <6 (and why?). Will give it a proper review soon, but glad to see the tests are passing!

gabceb commented 6 years ago

Looking forward to this @RealOrangeOne and @jasonfma. When I try to pull this branch as a dev dependency for my project running RN 0.50 and React 16 it complains when running haste.js as part of the post install

Error: EISDIR: illegal operation on a directory, read
    at Error (native)
    at Object.fs.readSync (fs.js:731:19)
    at tryReadSync (fs.js:486:20)
    at Object.fs.readFileSync (fs.js:534:19)
    at /Users/gabrielcebrian/Projects/tes/mobile/app-job-mobile/node_modules/react-native-mock/src/haste.js:32:39
    at Function._.each._.forEach (/Users/gabrielcebrian/Projects/tes/mobile/app-job-mobile/node_modules/underscore/underscore.js:153:9)
    at Object.<anonymous> (/Users/gabrielcebrian/Projects/tes/mobile/app-job-mobile/node_modules/react-native-mock/src/haste.js:31:3)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

If I clone the project on a different folder the post-install finishes as expected

EdenGottlieb commented 6 years ago

Adding a mock for FlatList would be a great idea, in my opinion.

jasonfma commented 6 years ago

@RealOrangeOne just to be clear, this is a PR into the rewrite branch that you created. This is not a merge into master.

jasonfma commented 6 years ago

@RealOrangeOne Looks like node 8.0.0 is broken. I'm going to set to 8.9.1 since it's the first LTS version.

RealOrangeOne commented 6 years ago

Just seen the build log, agreed that's very weird. I think sticking to that version will probably be fine, it's early enough!

jasonfma commented 6 years ago

@RealOrangeOne can you rebuild? I think it failed because of https://github.com/npm/registry/issues/255

jasonfma commented 6 years ago

dustinsavery commented on Nov 9, 2017 Should probably add react, react-dom, and react-native as dev dependencies also. When trying to build locally without those packages, it fails

I think this is set up this way so the build can test with various versions of each. I did add them as peerDeps so you can see the warnings.

@RealOrangeOne comments addressed

jasonfma commented 6 years ago

@RealOrangeOne will you have some time soon to take a look? I'm happy to help here where I can too. This PR is to merge into your existing rewrite branch #120 where there are still some merge conflicts to resolve as well - so this is not final or going into master.

RealOrangeOne commented 6 years ago

All these changes look good to me! Let's get this into rewrite and see how it affects it!

lalop commented 6 years ago

I tried rewrite branch but I get this error

Cannot find module './build/react-native-mock.js' from 'mock.js'

Will we use this branch as master ?

RealOrangeOne commented 6 years ago

If you're downloading straight from GitHub, you'll have to build the compiled code to actually use it.

Yes, this code will eventually be pushed into master. Time frame unknown, but shouldn't be too long!

lalop commented 6 years ago

I get it via yarn, but build folder isn't present. Is that normal ?

RealOrangeOne commented 6 years ago

Yarn, npm, makes no difference. We don't commit the build/ directory for obviousl reasons, committing build artifacts is bad practice. If you want to use a version from somewhere other than npm, you'll need to run the build yourself from the project directory, else you'll only have the source files, which won't work.

lalop commented 6 years ago

I'm agree with you but I'm not sure to understand. I get react-native-mock via yarn, that provide source code not built but https://github.com/RealOrangeOne/react-native-mock/blob/rewrite/mock.js call ./build/react-native-mock.js so is there something wrong here or should I build the package even if I get it via npm/yarn ?

RealOrangeOne commented 6 years ago

hmm, this sounds odd, and probably not the best place to discuss. Perhaps raise an actual issue so it can be looked into properly

lalop commented 6 years ago

done https://github.com/RealOrangeOne/react-native-mock/issues/157