mirror of
https://github.com/kremalicious/ipfs.git
synced 2025-01-04 02:45:12 +01:00
19 lines
558 B
TypeScript
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
|
||
|
}
|
||
|
}
|
||
|
}
|