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 ListApp from '../e2e-apps/ListApp';
    
  8. import ListAppLegacy from '../e2e-apps/ListAppLegacy';
    
  9. import {gte} from 'react-devtools-shared/src/backend/utils';
    
  10. 
    
  11. const version = process.env.E2E_APP_REACT_VERSION;
    
  12. 
    
  13. function mountApp(App: () => React$Node) {
    
  14.   const container = document.createElement('div');
    
  15. 
    
  16.   ((document.body: any): HTMLBodyElement).appendChild(container);
    
  17. 
    
  18.   ReactDOM.render(<App />, container);
    
  19. }
    
  20. function mountTestApp() {
    
  21.   // ListApp has hooks, which aren't available until 16.8.0
    
  22.   mountApp(gte(version, '16.8.0') ? ListApp : ListAppLegacy);
    
  23. }
    
  24. 
    
  25. mountTestApp();
    
  26. 
    
  27. // ReactDOM Test Selector APIs used by Playwright e2e tests
    
  28. // If they don't exist, we mock them
    
  29. window.parent.REACT_DOM_APP = {
    
  30.   createTestNameSelector: name => `[data-testname="${name}"]`,
    
  31.   findAllNodes: (container, nodes) =>
    
  32.     container.querySelectorAll(nodes.join(' ')),
    
  33.   ...ReactDOM,
    
  34. };