mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-15 00:04:59 +08:00
19 lines
752 B
TypeScript
19 lines
752 B
TypeScript
|
import { TextEncoder } from "util";
|
||
|
import JSDOMEnvironment_, {
|
||
|
TestEnvironment as TestEnvironment_,
|
||
|
} from "jest-environment-jsdom";
|
||
|
import { JestEnvironmentConfig, EnvironmentContext } from "@jest/environment";
|
||
|
|
||
|
// This is a patched version of jsdom that adds TextEncoder, as a workaround for
|
||
|
// https://github.com/jsdom/jsdom/issues/2524
|
||
|
// Once that issue is resolved, this custom environment file can be deleted
|
||
|
export default class JSDOMEnvironment extends JSDOMEnvironment_ {
|
||
|
constructor(config: JestEnvironmentConfig, context: EnvironmentContext) {
|
||
|
super(config, context);
|
||
|
this.global.TextEncoder ??= TextEncoder;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export const TestEnvironment =
|
||
|
TestEnvironment_ === JSDOMEnvironment_ ? JSDOMEnvironment : TestEnvironment_;
|