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

ReactTestRendererAsync-test.js — react Source File

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

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
 * @jest-environment node
 */

'use strict';

let React;
let ReactTestRenderer;
let Scheduler;
let waitForAll;
let waitFor;

describe('ReactTestRendererAsync', () => {
  beforeEach(() => {
    jest.resetModules();

    React = require('react');
    ReactTestRenderer = require('react-test-renderer');
    Scheduler = require('scheduler');

    const InternalTestUtils = require('internal-test-utils');
    waitForAll = InternalTestUtils.waitForAll;
    waitFor = InternalTestUtils.waitFor;
  });

  it('flushAll flushes all work', async () => {
    function Foo(props) {
      return props.children;
    }
    const renderer = ReactTestRenderer.create(<Foo>Hi</Foo>, {
      unstable_isConcurrent: true,
    });

    // Before flushing, nothing has mounted.
    expect(renderer.toJSON()).toEqual(null);

    // Flush initial mount.
    await waitForAll([]);
    expect(renderer.toJSON()).toEqual('Hi');

    // Update
    renderer.update(<Foo>Bye</Foo>);
    // Not yet updated.
    expect(renderer.toJSON()).toEqual('Hi');
    // Flush update.
    await waitForAll([]);
    expect(renderer.toJSON()).toEqual('Bye');
  });

  it('flushAll returns array of yielded values', async () => {
    function Child(props) {
      Scheduler.log(props.children);
      return props.children;
    }
// ... (97 more lines)

Domain

Subdomains

Classes

Frequently Asked Questions

What does ReactTestRendererAsync-test.js do?
ReactTestRendererAsync-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
Where is ReactTestRendererAsync-test.js in the architecture?
ReactTestRendererAsync-test.js is located at packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-test-renderer/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free