Better use package jest-fixed-jsdom
, this solves the problem of nodejs globals.
npm i jest-fixed-jsdom
Then update jest.config.js
module.exports = {
testEnvironment: 'jest-fixed-jsdom',
}
You can read more about this here https://mswjs.io/docs/faq/#requestresponsetextencoder-is-not-defined-jest