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
React Native support #104
Comments
This is so awesome! I'm glad to see it was relatively easy to get working with React Native as several folks have been asking about it. Thanks for putting this together 👍 We are decoupling Mirage from Pretender so it can be All that to say, I think your patch makes a ton of sense for Pretender and would just help eliminate more weird edge cases that pop up in the uncanny, browser-like-but-not-really situations. I think we should try to get it upstreamed to Pretender! |
aye-aye! PR'd so 🤞: pretenderjs/pretender#267 Thanks for this project! I've been wanting something like this forever. Excited to help out and watch it grow |
I'm coming daily to check on this issue! 🙌 |
Is this still being worked on? |
Also interested to know if it's still being worked on. |
Lots of folks have been asking so it is on our list! Still catching up on some issues since the site launch but we should push forward on this. Looks like the Pretender issue would be the next step if someone wants to pick that up. New PR that copies the code might be the fastest way to get it moving so no one is blocked! |
Hi 👋 I'm currently using Mirage for a React Native app and I ran into some issues while writing some tests. In order to make Mirage work I did the following:
The
After doing that I was able to create a server instance on my tests, define the different responses for the same endpoint and verify that pretender had handled the network requests as expected. Hope that the steps shared above will help others use Mirage on their app until official support lands! @samselikoff I think I'll have time this week to help out with the original PR that was created on the Pretender repo. |
Awesome, thanks so much! Getting your instructions into a QuickStart would also be 💯 |
I'd be happy to add a PR to the site repo with the QuickStart guide. |
if anyone is curious about trying this - i had to update the |
It's also worth mentioning that the instructions shared for testing #104 (comment) will also need the Pretender fix. Hopefully we can land the Pretender update soon. I created a PR on Monday and I'm waiting for some feedback from the maintainers. pretenderjs/pretender#288 |
@samselikoff I'll also try to land a PR in Pretender to remove the dependency of |
This is all set! ✨ Check out the new quickstart guides here: |
React Native's network stack is pretty compatible with the browser's so I don't think it would be much of a stretch to officially support React Native.
I was able to get a minimal example working with a few tweaks:
self
is available. Using RN-browser-polyfill to exposeglobal
asself
before importing mirage fixed this. We could guard against this, but the polyfill seems to be a common enough solution for this in RN.document.createElement('a')
to parse URLs which isn't available in mobile. I "fixed" this by patching mirage's umd'dparseUrl
to fall back tourl-parse
. This should be fixed upstream or we can at least move the patch to mirage itself.@samselikoff mentioned some de-
pretender
ingthat's happening for node support, so that may also be an option 💯The text was updated successfully, but these errors were encountered: