I am trying to test apiwrapper in a reaction based application using jest (integration testing). When I run it in the iOS simulator everything works fine, but it does not run my jest tests correctly - I always get:
ReferenceError: XMLHttpRequest is not defined
when I try to run tests using my api shell, for example:
it('Login successful with correct data', () => { let api = Api.getInstance(); return api.login("test", "testpass") .then(result => expect(result).toEqual('login_successful')); });
The api class I'm trying to check here uses the fetch api (and not vanilla xhr). I suppose this has something to do with a joke trying to mock something, but has not yet found a way to make it work.
Thanks in advance.
source share