forked from CodebuffAI/codebuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
25 lines (24 loc) · 968 Bytes
/
Copy pathjest.setup.js
File metadata and controls
25 lines (24 loc) · 968 Bytes
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
import '@testing-library/jest-dom'
import { TextDecoder, TextEncoder } from 'node:util'
import { ReadableStream, WritableStream, TransformStream } from 'node:stream/web'
// JSDOM lacks Node's Web API globals — undici (loaded transitively via
// `next/server` and `openai`) needs these at module-load time.
if (typeof globalThis.TextEncoder === 'undefined') {
globalThis.TextEncoder = TextEncoder
}
if (typeof globalThis.TextDecoder === 'undefined') {
globalThis.TextDecoder = TextDecoder
}
if (typeof globalThis.ReadableStream === 'undefined') {
globalThis.ReadableStream = ReadableStream
globalThis.WritableStream = WritableStream
globalThis.TransformStream = TransformStream
}
if (typeof globalThis.Request === 'undefined') {
const undici = require('undici')
globalThis.Request = undici.Request
globalThis.Response = undici.Response
globalThis.Headers = undici.Headers
globalThis.fetch = undici.fetch
globalThis.FormData = undici.FormData
}