Home / File/ ReactDOMServerFB-test.internal.js — react Source File

ReactDOMServerFB-test.internal.js — react Source File

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

Entity Profile

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 ReactDOMServer;
let Suspense;

describe('ReactDOMServerFB', () => {
  beforeEach(() => {
    jest.resetModules();
    React = require('react');
    ReactDOMServer = require('../ReactDOMServerFB');
    Suspense = React.Suspense;
  });

  const theError = new Error('This is an error');
  function Throw() {
    throw theError;
  }
  const theInfinitePromise = new Promise(() => {});
  function InfiniteSuspend() {
    throw theInfinitePromise;
  }

  function readResult(stream) {
    let result = '';
    while (!ReactDOMServer.hasFinished(stream)) {
      result += ReactDOMServer.renderNextChunk(stream);
    }
    return result;
  }

  it('should be able to render basic HTML', async () => {
    const stream = ReactDOMServer.renderToStream(<div>hello world</div>, {
      onError(x) {
        console.error(x);
      },
    });
    const result = readResult(stream);
    expect(result).toMatchInlineSnapshot(`"<div>hello world</div>"`);
  });

  it('should emit bootstrap script src at the end', () => {
    const stream = ReactDOMServer.renderToStream(<div>hello world</div>, {
      bootstrapScriptContent: 'INIT();',
      bootstrapScripts: ['init.js'],
      bootstrapModules: ['init.mjs'],
      onError(x) {
        console.error(x);
      },
    });
    const result = readResult(stream);
// ... (157 more lines)

Frequently Asked Questions

What does ReactDOMServerFB-test.internal.js do?
ReactDOMServerFB-test.internal.js is a source file in the react codebase, written in javascript.
Where is ReactDOMServerFB-test.internal.js in the architecture?
ReactDOMServerFB-test.internal.js is located at packages/react-server-dom-fb/src/__tests__/ReactDOMServerFB-test.internal.js (directory: packages/react-server-dom-fb/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free