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

ReactFlight-test.js — react Source File

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

File javascript BabelCompiler Validation 5 functions 5 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
 * @jest-environment node
 */

'use strict';

if (typeof Blob === 'undefined') {
  global.Blob = require('buffer').Blob;
}
if (typeof File === 'undefined' || typeof FormData === 'undefined') {
  global.File = require('undici').File;
  global.FormData = require('undici').FormData;
}

function normalizeCodeLocInfo(str) {
  return (
    str &&
    str.replace(/^ +(?:at|in) ([\S]+)[^\n]*/gm, function (m, name) {
      const dot = name.lastIndexOf('.');
      if (dot !== -1) {
        name = name.slice(dot + 1);
      }
      return '    in ' + name + (/\d/.test(m) ? ' (at **)' : '');
    })
  );
}

function normalizeReactCodeLocInfo(str) {
  const repoRootForRegexp = __REACT_ROOT_PATH_TEST__.replace(/\//g, '\\/');
  const repoFileLocMatch = new RegExp(`${repoRootForRegexp}.+?:\\d+:\\d+`, 'g');
  return str && str.replace(repoFileLocMatch, '**');
}

// If we just use the original Error prototype, Jest will only display the error message if assertions fail.
// But we usually want to also assert on our expando properties or even the stack.
// By hiding the fact from Jest that this is an error, it will show all enumerable properties on mismatch.

function getErrorForJestMatcher(error) {
  return {
    ...error,
    // non-enumerable properties that are still relevant for testing
    message: error.message,
    stack: normalizeReactCodeLocInfo(error.stack),
  };
}

const finalizationRegistries = [];
function FinalizationRegistryMock(callback) {
  this._heldValues = [];
  this._callback = callback;
  finalizationRegistries.push(this);
}
FinalizationRegistryMock.prototype.register = function (target, heldValue) {
  this._heldValues.push(heldValue);
// ... (4001 more lines)

Domain

Subdomains

Frequently Asked Questions

What does ReactFlight-test.js do?
ReactFlight-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 ReactFlight-test.js?
ReactFlight-test.js defines 5 function(s): FinalizationRegistryMock, gc, getErrorForJestMatcher, normalizeCodeLocInfo, normalizeReactCodeLocInfo.
Where is ReactFlight-test.js in the architecture?
ReactFlight-test.js is located at packages/react-client/src/__tests__/ReactFlight-test.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-client/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free