ReferenceError: Response is not defined

See original GitHub issue

Hi!

I’m experiencing a strange bug today. I was using your module successfully until this morning when suddenly all my test suites failed with error:

Test suite failed to run

    ReferenceError: Response is not defined

      at Object.<anonymous> (node_modules/jest-fetch-mock/src/index.js:11:24)
      at Object.<anonymous> (__tests__/setupJest.js:1:103)

The only thing I did was removing my node-modules folder and then npm install them again. I imagine that I had some modules (or version of modules) in cache that disappeared with the rm command and were replaced by a new one after that. 🤔 But it doesn’t seems that any module associated with jest-fetch-mock has changed since yesterday.

I’ve attached a little project that should reproduce the bug. Just unzip it and run:

npm install
npm test

Thanks in advance for your help!

BugFetchJest.zip

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:15
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

25reactions
FredericRuaudelcommented, Feb 22, 2017

ok, I’ve fixed my issue by adding import 'isomorphic-fetch' at the beginning of my setupJest.js file. But I still don’t understand how it was working previously without it…

24reactions
wwwdatacommented, May 5, 2017

I’m doing it like this in my jest setup file now:

const { Response, Headers, Request } = require('whatwg-fetch');

global.Response = Response;
global.Headers = Headers;
global.Request = Request;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I getting ReferenceError: Response is not defined?
I am trying to set up a basic server, but have no idea why I am getting a response error. var http =...
Read more >
ReferenceError: Response is not defined #7007 - GitHub
Response is not a global in Node or JSDOM, so you have to polyfill it (by importing isomorphic-fetch or whatwg-fetch in a setup...
Read more >
ReferenceError: response is not defined (Example) - Treehouse
ReferenceError : response is not defined. When go to the server I am getting the following error: Server running at http://<workspace-url>/ ...
Read more >
Wanderlust - ReferenceError: response is not defined main.js ...
I'm having issues with step 13, when I try to check the browsers javascript console it keeps saying “ReferenceError: response is not defined...
Read more >
Uncaught ReferenceError in Ajax get method - Laracasts
I'm tired this week bez of this one error.. here it show error like that........ create:209 Uncaught ReferenceError: response is not defined at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found