4

I am using msw/node with my react-testing-library integration test.

When we mock fetch api with msw/node, we have to use polyfills for that since node does not support browser specific api such as localstorage, fetch.

msw documentation also states that we have to use polyfills for unsupported features.

It seems that we can use whatwg-fetch for mocking fetch api in msw/node environment as others suggest.

But whatwg-fetch states that we cannot use them in node environment, and this is why I am confused.

Is this collision happening because msw/node's environment is not a native node environment? It seems that both jest and msw/node runs on node environment, and what makes msw/node environment enable to use whatwg-fetch available?

Thank you.

jwkoo
  • 2,393
  • 5
  • 22
  • 35

0 Answers0