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.  */
    
  9. 'use strict';
    
  10. 
    
  11. let React;
    
  12. let ReactDOM;
    
  13. 
    
  14. describe('ReactError', () => {
    
  15.   let globalErrorMock;
    
  16. 
    
  17.   beforeEach(() => {
    
  18.     if (!__DEV__) {
    
  19.       // In production, our Jest environment overrides the global Error
    
  20.       // class in order to decode error messages automatically. However
    
  21.       // this is a single test where we actually *don't* want to decode
    
  22.       // them. So we assert that the OriginalError exists, and temporarily
    
  23.       // set the global Error object back to it.
    
  24.       globalErrorMock = global.Error;
    
  25.       global.Error = globalErrorMock.OriginalError;
    
  26.       expect(typeof global.Error).toBe('function');
    
  27.     }
    
  28.     jest.resetModules();
    
  29.     React = require('react');
    
  30.     ReactDOM = require('react-dom');
    
  31.   });
    
  32. 
    
  33.   afterEach(() => {
    
  34.     if (!__DEV__) {
    
  35.       global.Error = globalErrorMock;
    
  36.     }
    
  37.   });
    
  38. 
    
  39.   // @gate build === "production"
    
  40.   // @gate !source
    
  41.   it('should error with minified error code', () => {
    
  42.     expect(() => ReactDOM.render('Hi', null)).toThrowError(
    
  43.       'Minified React error #200; visit ' +
    
  44.         'https://reactjs.org/docs/error-decoder.html?invariant=200' +
    
  45.         ' for the full message or use the non-minified dev environment' +
    
  46.         ' for full errors and additional helpful warnings.',
    
  47.     );
    
  48.   });
    
  49. 
    
  50.   it('should serialize arguments', () => {
    
  51.     function Oops() {
    
  52.       return;
    
  53.     }
    
  54.     Oops.displayName = '#wtf';
    
  55.     const container = document.createElement('div');
    
  56.     expect(() => ReactDOM.render(<Oops />, container)).not.toThrowError();
    
  57.   });
    
  58. });