Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No fetch avaibale. Unable to register fetch-intercept #44

Open
alexey2baranov opened this issue Jan 7, 2020 · 1 comment
Open

No fetch avaibale. Unable to register fetch-intercept #44

alexey2baranov opened this issue Jan 7, 2020 · 1 comment

Comments

@alexey2baranov
Copy link

in Jest test

import fetch from 'node-fetch'
global.fetch= fetch
import fetchIntercept from "fetch-intercept";

throws

● Test suite failed to run

No fetch avaibale. Unable to register fetch-intercept

  10 | 
  11 | // fetchIntercept.register(errorInterceptor)
> 12 | // fetchIntercept.register(dataInterceptor)
     |                                              ^
  13 | // fetchIntercept.register(cookieInterceptor)
  14 | // fetchIntercept.register(headersInterceptor)
  15 | 

  at attach (node_modules/fetch-intercept/lib/webpack:/src/attach.js?1269:38:13)
  at Object.<anonymous> (node_modules/fetch-intercept/lib/webpack:/src/node.js:3:18)
  at Object.<anonymous> (node_modules/fetch-intercept/lib/node.js:53:31)
  at __webpack_require__ (node_modules/fetch-intercept/lib/webpack:/webpack/bootstrap 288f28a76d94cd56de0b?2753:19:1)
  at node_modules/fetch-intercept/lib/webpack:/webpack/bootstrap 288f28a76d94cd56de0b?2753:39:1
  at Object.<anonymous> (node_modules/fetch-intercept/lib/node.js:44:10)
  at Object.<anonymous> (src/api/index.js:12:46)
  at Object.<anonymous> (src/plugins/bottle.js:24:35)
  at Object.<anonymous> (src/models/AbstractSync.js:25:15)
  at Object.<anonymous> (src/models/index.js:27:44)
  at Object.<anonymous> (src/plugins/className.js:5:38)
  at Object.<anonymous> (tests/test-setup.js:30:1)
@Shishir-Tiwari
Copy link

Shishir-Tiwari commented Aug 14, 2020

While running in node environment, fetch-intercept uses whatwg-fetch pollyfill but since it is not included in dependencies, it is not available and hence generates this error.

https://github.com/werk85/fetch-intercept/blob/develop/src/attach.js#L36

As a workaround, adding whatwg-fetch@3.2.0 as a dev dependency in the main project worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants