RealOrangeOne / react-native-mock

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

fetch() doesn't save cookies #125

Closed GeoffreyPlitt closed 7 years ago

GeoffreyPlitt commented 7 years ago

In production, fetch() saves cookies as you would expect against an API that does cookie-based session login authentication.

But our tests with the same code (and react-native-mock) show fetch() not sending cookies on subsequent calls after login(), so I believe it's correct to say react-native-mock's fetch() has a bug with cookies.

RealOrangeOne commented 7 years ago

This is a strange bug, however generally i'd be against actually calling an API in your tests using fetch. The response should be stubbed so it can be reliably asserted against.

Closing as a mix of non-issue, and possibly outside our codebase.

GeoffreyPlitt commented 7 years ago

Actually, I just solved it. To anyone else curious: just use this: https://www.npmjs.com/package/fetch-cookie