forked from xmtp/xmtp-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.jsdom.env.js
22 lines (20 loc) · 740 Bytes
/
jest.jsdom.env.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* eslint-disable @typescript-eslint/no-var-requires */
const Environment = require('jest-environment-jsdom')
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.crypto === 'undefined') {
this.global.crypto = require('crypto').webcrypto
}
// https://github.com/facebook/jest/issues/9983
this.global.Uint8Array = Uint8Array
}
}