RealOrangeOne / react-native-mock

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

Does it support mock fetch? #136

Closed zhouzhongyuan closed 7 years ago

zhouzhongyuan commented 7 years ago

If no, will it support fetch, and when? If yes, how?

RealOrangeOne commented 7 years ago

What do you mean by Mock Fetch? If youre trying to use a library that mocks fetch(), then yes that should work fine.

zhouzhongyuan commented 7 years ago

Yes, I mean using a library to mock fetch(). I am using react-native-fetch-mock to mocks fetch() now. But its return value is not a Response, its return value is json. As I know, React-native doesn't have a Response constructor. Every method trying to mocks fetch() won't return a right value in Response type. Is it mean I can't mock fetch() properly? Do you have any good library to mock fetch() ? Thank you.

RealOrangeOne commented 7 years ago

I've never used fetch-mock. But the missing Response constructor shouldnt matter too much, as you dont actually want to be making a request in your tests.

I dont know of any good libraries, i'd suggest the best solution might be to make your own using mockery.

I'm not sure this is related to this library, so closing until more information can be found.