Home / File/ ReactConfigurableErrorLogging-test.js — react Source File

ReactConfigurableErrorLogging-test.js — react Source File

Architecture documentation for ReactConfigurableErrorLogging-test.js, a javascript file in the react codebase.

File javascript BabelCompiler Validation 1 functions 2 classes

Entity Profile

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @emails react-core
 */

'use strict';

let React;
let ReactDOMClient;
let Scheduler;
let container;
let act;

async function fakeAct(cb) {
  // We don't use act/waitForThrow here because we want to observe how errors are reported for real.
  await cb();
  Scheduler.unstable_flushAll();
}

describe('ReactConfigurableErrorLogging', () => {
  beforeEach(() => {
    jest.resetModules();
    React = require('react');
    ReactDOMClient = require('react-dom/client');
    Scheduler = require('scheduler');
    container = document.createElement('div');
    if (__DEV__) {
      act = React.act;
    }
  });

  it('should log errors that occur during the begin phase', async () => {
    class ErrorThrowingComponent extends React.Component {
      constructor(props) {
        super(props);
        throw new Error('constructor error');
      }
      render() {
        return <div />;
      }
    }
    const uncaughtErrors = [];
    const caughtErrors = [];
    const root = ReactDOMClient.createRoot(container, {
      onUncaughtError(error, errorInfo) {
        uncaughtErrors.push(error, errorInfo);
      },
      onCaughtError(error, errorInfo) {
        caughtErrors.push(error, errorInfo);
      },
    });
    await fakeAct(() => {
      root.render(
        <div>
          <span>
            <ErrorThrowingComponent />
// ... (170 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does ReactConfigurableErrorLogging-test.js do?
ReactConfigurableErrorLogging-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactConfigurableErrorLogging-test.js?
ReactConfigurableErrorLogging-test.js defines 1 function(s): fakeAct.
Where is ReactConfigurableErrorLogging-test.js in the architecture?
ReactConfigurableErrorLogging-test.js is located at packages/react-reconciler/src/__tests__/ReactConfigurableErrorLogging-test.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-reconciler/src/__tests__).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free