Using Jest even after doing fetch.mockResponse actual fetch is getting called
I am new to react and trying to writing my first test case using Jest. I have to mock a fetch response. I am using jest-fetch-mock. But the call is going to actual fetch and data returned is undefined. package.json : "jest-fetch-mock": "^2.1.2" setupTest.js file global.fetch = require('jest-fetch-mock'); Actual api call method: static fetchUserInfo(){ return dispatch => { fetch('https://localhost:55001/api/userInfo') .then(this.httpResponseHandler.handleHttpResponse) .then ((resp) => resp.json()) .then(data => dispatch(this.onUserInfoGetSuccess(data))) .catch( error => { dispatch(this.onFetchF
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.