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

utils-test.js — react Source File

Architecture documentation for utils-test.js, a javascript file in the react codebase. 8 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  bc9318d5_95fe_5bef_9896_4557f31e8d9d["utils-test.js"]
  165c2fb6_ea87_519d_8825_3b32e0b24ca4["symbolicateSource.js"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> 165c2fb6_ea87_519d_8825_3b32e0b24ca4
  5094f555_7132_4482_8a41_568283ebfed9["symbolicateSource"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> 5094f555_7132_4482_8a41_568283ebfed9
  627bb742_21aa_b4fd_fe2d_4a963a1f9278["utils"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> 627bb742_21aa_b4fd_fe2d_4a963a1f9278
  15ddbedd_95dc_5545_807f_882c0a98271f["utils"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> 15ddbedd_95dc_5545_807f_882c0a98271f
  80162ac2_4fc9_259b_04e9_4acc940af136["utils"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> 80162ac2_4fc9_259b_04e9_4acc940af136
  f54d6bee_ceba_3ace_accc_fb59870f6fb5["parseStackTrace"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> f54d6bee_ceba_3ace_accc_fb59870f6fb5
  e1e1de60_2be4_0643_45fb_e2c306735427["ReactSymbols"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> e1e1de60_2be4_0643_45fb_e2c306735427
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  style bc9318d5_95fe_5bef_9896_4557f31e8d9d fill:#6366f1,stroke:#818cf8,color:#fff

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.
 *
 * @flow
 */

import {
  getDisplayName,
  getDisplayNameForReactElement,
  isPlainObject,
} from 'react-devtools-shared/src/utils';
import {stackToComponentLocations} from 'react-devtools-shared/src/devtools/utils';
import {
  formatConsoleArguments,
  formatConsoleArgumentsToSingleString,
  formatWithStyles,
  gt,
  gte,
} from 'react-devtools-shared/src/backend/utils';
import {extractLocationFromComponentStack} from 'react-devtools-shared/src/backend/utils/parseStackTrace';
import {
  REACT_SUSPENSE_LIST_TYPE as SuspenseList,
  REACT_STRICT_MODE_TYPE as StrictMode,
} from 'shared/ReactSymbols';
import {createElement} from 'react';
import {symbolicateSource} from '../symbolicateSource';

describe('utils', () => {
  describe('getDisplayName', () => {
    // @reactVersion >= 16.0
    it('should return a function name', () => {
      function FauxComponent() {}
      expect(getDisplayName(FauxComponent)).toEqual('FauxComponent');
    });

    // @reactVersion >= 16.0
    it('should return a displayName name if specified', () => {
      function FauxComponent() {}
      FauxComponent.displayName = 'OverrideDisplayName';
      expect(getDisplayName(FauxComponent)).toEqual('OverrideDisplayName');
    });

    // @reactVersion >= 16.0
    it('should return the fallback for anonymous functions', () => {
      expect(getDisplayName(() => {}, 'Fallback')).toEqual('Fallback');
    });

    // @reactVersion >= 16.0
    it('should return Anonymous for anonymous functions without a fallback', () => {
      expect(getDisplayName(() => {})).toEqual('Anonymous');
    });

    // Simulate a reported bug:
    // https://github.com/facebook/react/issues/16685
    // @reactVersion >= 16.0
    it('should return a fallback when the name prop is not a string', () => {
      const FauxComponent = {name: {}};
// ... (446 more lines)

Domain

Dependencies

Frequently Asked Questions

What does utils-test.js do?
utils-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does utils-test.js depend on?
utils-test.js imports 8 module(s): ReactSymbols, parseStackTrace, react, symbolicateSource, symbolicateSource.js, utils, utils, utils.
Where is utils-test.js in the architecture?
utils-test.js is located at packages/react-devtools-shared/src/__tests__/utils-test.js (domain: BabelCompiler, directory: packages/react-devtools-shared/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free