forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReactDOMServerIntegrationEnvironment.js
More file actions
34 lines (27 loc) · 1.05 KB
/
ReactDOMServerIntegrationEnvironment.js
File metadata and controls
34 lines (27 loc) · 1.05 KB
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
29
30
31
32
33
34
'use strict';
const ReactJSDOMEnvironment = require('./ReactJSDOMEnvironment');
const {TestEnvironment: NodeEnvironment} = require('jest-environment-node');
/**
* Test environment for testing integration of react-dom (browser) with react-dom/server (node)
*/
class ReactDOMServerIntegrationEnvironment extends NodeEnvironment {
constructor(config, context) {
super(config, context);
this.domEnvironment = new ReactJSDOMEnvironment(config, context);
this.global.window = this.domEnvironment.dom.window;
this.global.document = this.global.window.document;
this.global.navigator = this.global.window.navigator;
this.global.Node = this.global.window.Node;
this.global.addEventListener = this.global.window.addEventListener;
this.global.MutationObserver = this.global.window.MutationObserver;
}
async setup() {
await super.setup();
await this.domEnvironment.setup();
}
async teardown() {
await this.domEnvironment.teardown();
await super.teardown();
}
}
module.exports = ReactDOMServerIntegrationEnvironment;