forked from authts/oidc-client-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-environment-jsdom.cjs
28 lines (24 loc) · 1011 Bytes
/
jest-environment-jsdom.cjs
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
'use strict';
const { TextEncoder, TextDecoder } = require('util');
const { default: $JSDOMEnvironment, TestEnvironment } = require('jest-environment-jsdom');
const crypto = require("crypto");
Object.defineProperty(exports, '__esModule', {
value: true
});
class JSDOMEnvironment extends $JSDOMEnvironment {
constructor(...args) {
const { global } = super(...args);
// see https://github.com/jsdom/jsdom/issues/2524
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
// see https://github.com/jestjs/jest/issues/9983
global.Uint8Array = Uint8Array;
global.crypto.subtle = crypto.subtle;
global.crypto.randomUUID = crypto.randomUUID;
// see https://github.com/dumbmatter/fakeIndexedDB#jsdom-often-used-with-jest
global.structuredClone = structuredClone;
}
}
exports.default = JSDOMEnvironment;
exports.TestEnvironment = TestEnvironment === $JSDOMEnvironment ?
JSDOMEnvironment : TestEnvironment;