1
0
mirror of https://github.com/kremalicious/ipfs.git synced 2024-11-24 10:52:31 +01:00
ipfs/test/__config__/jest.env.ts
2021-09-14 00:04:38 +02:00

19 lines
558 B
TypeScript

import Environment from 'jest-environment-jsdom'
/**
* A custom environment to set the TextEncoder required by ipfs-http-client.
*/
module.exports = class CustomTestEnvironment 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
}
}
}