-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest-setup.ts
34 lines (27 loc) · 1.06 KB
/
jest-setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import '@testing-library/jest-dom';
// import 'isomorphic-fetch';
// import React from 'react';
// global.React = React; // this also works for other globally available libraries
// (global as any).useState = React.useState;
import { TextDecoder, TextEncoder } from 'node:util';
const { ReadableStream, TransformStream } = 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 },
});
// @ts-ignore
// import {Readable} from 'readable-stream';
// Object.assign(global, { TextDecoder, TextEncoder });
// Object.assign(global, { ReadableStream, TransformStream });