forked from auth0/react-native-auth0
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.environment.js
More file actions
27 lines (23 loc) · 777 Bytes
/
jest.environment.js
File metadata and controls
27 lines (23 loc) · 777 Bytes
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
import JSDOMEnvironment from 'jest-environment-jsdom';
import fetch, { Headers, Request, Response } from 'node-fetch';
import { TextEncoder, TextDecoder } from 'util';
/**
* Custom Jest Environment based on JSDOMEnvironment to support TextEncoder and TextDecoder.
*
* ref: https://github.com/jsdom/jsdom/issues/2524
*/
export default class CustomJSDOMEnvironment extends JSDOMEnvironment {
constructor(config, context) {
super(config, context);
}
async setup() {
await super.setup();
this.global.fetch = fetch;
this.global.Headers = Headers;
this.global.Request = Request;
this.global.Response = Response;
this.global.TextEncoder = TextEncoder;
this.global.TextDecoder = TextDecoder;
}
}
module.exports = CustomJSDOMEnvironment;