1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @emails react-core
    
  8.  * @jest-environment node
    
  9.  */
    
  10. 
    
  11. 'use strict';
    
  12. 
    
  13. let React;
    
  14. let ReactNoop;
    
  15. let waitForAll;
    
  16. let waitForThrow;
    
  17. 
    
  18. describe('ReactIncrementalErrorReplay', () => {
    
  19.   beforeEach(() => {
    
  20.     jest.resetModules();
    
  21.     React = require('react');
    
  22.     ReactNoop = require('react-noop-renderer');
    
  23. 
    
  24.     const InternalTestUtils = require('internal-test-utils');
    
  25.     waitForAll = InternalTestUtils.waitForAll;
    
  26.     waitForThrow = InternalTestUtils.waitForThrow;
    
  27.   });
    
  28. 
    
  29.   it('should fail gracefully on error in the host environment', async () => {
    
  30.     ReactNoop.render(<errorInBeginPhase />);
    
  31.     await waitForThrow('Error in host config.');
    
  32.   });
    
  33. 
    
  34.   it("should ignore error if it doesn't throw on retry", async () => {
    
  35.     let didInit = false;
    
  36. 
    
  37.     function badLazyInit() {
    
  38.       const needsInit = !didInit;
    
  39.       didInit = true;
    
  40.       if (needsInit) {
    
  41.         throw new Error('Hi');
    
  42.       }
    
  43.     }
    
  44. 
    
  45.     class App extends React.Component {
    
  46.       render() {
    
  47.         badLazyInit();
    
  48.         return <div />;
    
  49.       }
    
  50.     }
    
  51.     ReactNoop.render(<App />);
    
  52.     await waitForAll([]);
    
  53.   });
    
  54. });