forked from xmtp/xmtp-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.jsdom.env.cjs
More file actions
42 lines (36 loc) · 1.44 KB
/
jest.jsdom.env.cjs
File metadata and controls
42 lines (36 loc) · 1.44 KB
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
35
36
37
38
39
40
41
42
/* eslint-disable @typescript-eslint/no-var-requires */
const Environment = require('jest-environment-jsdom').default
module.exports = class JsdomTestEnvironment extends Environment {
async setup() {
await super.setup()
if (typeof this.global.TextEncoder === 'undefined') {
const { TextEncoder } = require('util')
this.global.TextEncoder = TextEncoder
}
if (typeof this.global.TextDecoder === 'undefined') {
const { TextDecoder } = require('util')
this.global.TextDecoder = TextDecoder
}
if (typeof this.global.setImmediate === 'undefined') {
this.global.setImmediate = setImmediate
this.global.clearImmediate = clearImmediate
}
if (typeof this.global.crypto === 'undefined') {
this.global.crypto = require('crypto').webcrypto
}
if (typeof this.global.CompressionStream === 'undefined') {
// eslint-disable-next-line no-undef
this.global.CompressionStream = CompressionStream
}
if (typeof this.global.DecompressionStream === 'undefined') {
// eslint-disable-next-line no-undef
this.global.DecompressionStream = DecompressionStream
}
if (typeof this.global.performance.markResourceTiming === 'undefined') {
// eslint-disable-next-line @typescript-eslint/no-empty-function
this.global.performance.markResourceTiming = () => {}
}
// https://github.com/facebook/jest/issues/9983
this.global.Uint8Array = Uint8Array
}
}