forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-legacy.js
More file actions
34 lines (26 loc) · 1.04 KB
/
app-legacy.js
File metadata and controls
34 lines (26 loc) · 1.04 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
/** @flow */
// This test harness mounts each test app as a separate root to test multi-root applications.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import ListApp from '../e2e-apps/ListApp';
import ListAppLegacy from '../e2e-apps/ListAppLegacy';
import {gte} from 'react-devtools-shared/src/backend/utils';
const version = process.env.E2E_APP_REACT_VERSION;
function mountApp(App: () => React$Node) {
const container = document.createElement('div');
((document.body: any): HTMLBodyElement).appendChild(container);
ReactDOM.render(<App />, container);
}
function mountTestApp() {
// ListApp has hooks, which aren't available until 16.8.0
mountApp(gte(version, '16.8.0') ? ListApp : ListAppLegacy);
}
mountTestApp();
// ReactDOM Test Selector APIs used by Playwright e2e tests
// If they don't exist, we mock them
window.parent.REACT_DOM_APP = {
createTestNameSelector: name => `[data-testname="${name}"]`,
findAllNodes: (container, nodes) =>
container.querySelectorAll(nodes.join(' ')),
...ReactDOM,
};