1.0.0 • Published 6 months ago

jest-environment-jsdom-fetch v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

jest-environment-jsdom-fetch

This is jest-environment-jsdom plus the node global variables required for fetch to work.

By default jest does not include the node globals fetch, Blob, Request, Response, ReadableStream, TextDecoder and TextEncoder is the jsdom environment. This is to match the globals JSDOM has available, as it has not yet implemented these values.

Unfortunately, if the code you are testing uses these that is problematic. For example if you are using msw. The only way to add them back in is via a custom environment.

Using the Jest config.globals setting does not work for parallel tests.

Usage

npm install -d jest-environment-jsdom-fetch

In your jest config set config.jestEnvironment: 'jest-environment-jsdom-fetch'

1.0.0

6 months ago