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 ReactDOM from 'react-dom';
    
  7. import {createRoot} from 'react-dom/client';
    
  8. import ListApp from '../e2e-apps/ListApp';
    
  9. 
    
  10. function mountApp(App: () => React$Node) {
    
  11.   const container = document.createElement('div');
    
  12. 
    
  13.   ((document.body: any): HTMLBodyElement).appendChild(container);
    
  14. 
    
  15.   const root = createRoot(container);
    
  16.   root.render(<App />);
    
  17. }
    
  18. function mountTestApp() {
    
  19.   mountApp(ListApp);
    
  20. }
    
  21. 
    
  22. mountTestApp();
    
  23. 
    
  24. // ReactDOM Test Selector APIs used by Playwright e2e tests
    
  25. // If they don't exist, we mock them
    
  26. window.parent.REACT_DOM_APP = {
    
  27.   createTestNameSelector: name => `[data-testname="${name}"]`,
    
  28.   findAllNodes: (container, nodes) =>
    
  29.     container.querySelectorAll(nodes.join(' ')),
    
  30.   ...ReactDOM,
    
  31. };