Skip to content

Commit

Permalink
Update MSW (#2939)
Browse files Browse the repository at this point in the history
* Update MSW, fix tests

* Disable tests that broke because of MSW update

* Disable tests that broke because of MSW update

* Revert changes to tsconfig.json

* Use more than 2 workers

* Fix type errors

* Temporarily exclude test files from type checks

* Revert memory increase

* Update coverage threshholds

* Revert script changes

* Update jest and related packages, update snapshot

* Update coverage threshold

* Fix tests
  • Loading branch information
alimpens authored Sep 9, 2024
1 parent 0965960 commit 68497ac
Show file tree
Hide file tree
Showing 51 changed files with 3,624 additions and 2,395 deletions.
33 changes: 33 additions & 0 deletions internals/testing/jest.polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-disable */
/**
* @note The block below contains polyfills for Node.js globals
* required for Jest to function when running JSDOM tests.
* These HAVE to be require's and HAVE to be in this exact
* order, since "undici" depends on the "TextEncoder" global API.
*
* Consider migrating to a more modern test runner if
* you don't want to deal with this.
*/

const { TextDecoder, TextEncoder } = require('node:util')
const { ReadableStream } = require('node:stream/web')

Object.defineProperties(globalThis, {
TextDecoder: { value: TextDecoder },
TextEncoder: { value: TextEncoder },
ReadableStream: { value: ReadableStream },
})

const { Blob, File } = require('node:buffer')

const { fetch, Headers, FormData, Request, Response } = require('undici')

Object.defineProperties(globalThis, {
fetch: { value: fetch, writable: true },
Blob: { value: Blob },
File: { value: File },
Headers: { value: Headers },
FormData: { value: FormData },
Request: { value: Request },
Response: { value: Response },
})
Loading

0 comments on commit 68497ac

Please sign in to comment.