-
-
Notifications
You must be signed in to change notification settings - Fork 276
Expand file tree
/
Copy pathjest.environment.js
More file actions
19 lines (17 loc) · 800 Bytes
/
jest.environment.js
File metadata and controls
19 lines (17 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const { TestEnvironment } = require('jest-environment-jsdom');
// Custom test environment copied from https://github.com/jsdom/jsdom/issues/2524
// in order to add TextEncoder to jsdom. TextEncoder is expected by @noble/hashes.
module.exports = class CustomTestEnvironment extends TestEnvironment {
async setup() {
await super.setup();
if (typeof this.global.TextEncoder === 'undefined') {
// Needed for the JSDOM environment.
// eslint-disable-next-line no-shadow, n/prefer-global/text-encoder, n/prefer-global/text-decoder
const { TextEncoder, TextDecoder } = require('util');
this.global.TextEncoder = TextEncoder;
this.global.TextDecoder = TextDecoder;
this.global.ArrayBuffer = ArrayBuffer;
this.global.Uint8Array = Uint8Array;
}
}
};