main
js 30 lines 850 Bytes
Raw
1 /** @flow */
2
3 // This test harness mounts each test app as a separate root to test multi-root applications.
4
5 import * as React from 'react';
6 import * as ReactDOMClient from 'react-dom/client';
7 import ListApp from '../e2e-apps/ListApp';
8
9 function mountApp(App: () => React$Node) {
10 const container = document.createElement('div');
11
12 (document.body as any as HTMLBodyElement).appendChild(container);
13
14 const root = ReactDOMClient.createRoot(container);
15 root.render(<App />);
16 }
17 function mountTestApp() {
18 mountApp(ListApp);
19 }
20
21 mountTestApp();
22
23 // ReactDOM Test Selector APIs used by Playwright e2e tests
24 // If they don't exist, we mock them
25 window.parent.REACT_DOM_APP = {
26 createTestNameSelector: name => `[data-testname="${name}"]`,
27 findAllNodes: (container, nodes) =>
28 container.querySelectorAll(nodes.join(' ')),
29 ...ReactDOMClient,
30 };