So fetch-mock-jest is based on fetch-mock (it's not jest-fetch-mock..)
https://www.npmjs.com/package/fetch-mock-jest
http://www.wheresrhys.co.uk/fetch-mock/
The problem I have is:
// inside my test file
fetchMock.restore().mock('https://someSiteOnTheInternet.com', someResponse)
// inside my tested file
fetch('https://someSiteOnTheInternet.com').then(...)
The above is working but as soon as I try a local route it's not working anymore
// inside my test file
fetchMock.restore().mock('/myProxy', someResponse)
// inside my tested file
fetch('/myProxy').then(...)
This one ('/myProxy') will fail with the error :
console.error node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Error: connect ECONNREFUSED 127.0.0.1:80
Any idea what am I doing wrong here ?
80
, as it could be used by a running process during making the test. – Ahmad Shaarawi