-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Rest React Native example #60
base: main
Are you sure you want to change the base?
Conversation
Hi @taylorkline, no problem at all :) I've been working on an example repo as well, but spare time isn't something I have in adundance at the moment. My repo is at https://github.com/wwdrew/examples/tree/react-native The issue you're having is due to the examples project being a monorepo. It's installing the react-native module into the parent node_modules, so to compensate you need to update the paths in the project to point to the right place. You can see how I've done it in my repo. However, although I've managed to the get the iOS app building, the Android one was still giving me trouble. Additionally, the iOS build was failing when trying to download the JS bundle from Metro. I've not had any time to figure out why or how to fix these problems though, so hopefully this has given you some help on how to overcome these last hurdles. Also, although my example doesn't include e2e testing, I've included examples for using the REST API using fetch and react-query, as well as graphql using Apollo. |
Thanks so much @wwdrew, this is super useful. I plan to finish out this example when I have some free time, but I have been traveling and am behind on the day job. |
Without this polyfill, calling `server.start()` will result in an Error: not implemented message followed by Error: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect. This is due to the React Native URL polyfill that throws Not Implemented exceptions for functions that MSW calls.
This is the way of the future for React Native, so better to test against a Hermes build.
dc4e3bb
to
02d7046
Compare
Hey folks any update on this? |
Hi @ShivamJoker. I've picked it back up a couple times but now there are newer React Native versions. Likely need to start this example over from the newest React Native version. I might get to it eventually but if you're interested in taking it on please feel welcome to. |
Hey @taylorkline I will be happy to do it but I am unsure what other config we need to do to make it work? I see there is some polyfill, do we need to have this in the app source code or will it work if we do it in the tests file as well?
|
Introduction
Hi! I've seen you request assistance getting in an example in mswjs/msw#269, mswjs/msw#622, and mswjs/msw#203 for React Native. Here it finally is.
Changes
This PR, when finalized, adds a Rest React Native example for reference and smoke testing.
TODO
rest-react-native
is withinexamples/examples
,yarn pods
errors with the following output:When
rest-react-native
is copied to another directory,yarn pods
works fine. Can you help me figure out what it is about this directory structure / build setup that is causing issues?yarn test:unit
andyarn test:e2e
, but I am not sure how I can best help set this up with CircleCI.Other notes
Example checklist
npm test
.README.md
file to the root directory of my example.