mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 05:15:25 +02:00
chore(deps): upgrade to msw v2 [EE-6489] (#10911)
This commit is contained in:
parent
ecd603db8c
commit
400a80c07d
19 changed files with 2602 additions and 1669 deletions
42
app/setup-tests/jest-polyfills.ts
Normal file
42
app/setup-tests/jest-polyfills.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* eslint-disable import/order */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
const { TextDecoder, TextEncoder } = require('node:util');
|
||||
|
||||
Object.defineProperties(globalThis, {
|
||||
TextDecoder: { value: TextDecoder },
|
||||
TextEncoder: { value: TextEncoder },
|
||||
});
|
||||
|
||||
const { ReadableStream } = require('node:stream/web');
|
||||
|
||||
Object.defineProperties(globalThis, {
|
||||
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 },
|
||||
});
|
||||
|
||||
/* eslint-enable @typescript-eslint/no-var-requires */
|
||||
/* eslint-enable import/order */
|
Loading…
Add table
Add a link
Reference in a new issue