Home / File/ TestUtils.ts — react Source File

TestUtils.ts — react Source File

Architecture documentation for TestUtils.ts, a typescript file in the react codebase. 14 imports, 0 dependents.

File typescript BabelCompiler Validation 14 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  61433613_1614_4ece_2f7a_b0186e79adde["TestUtils.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  61433613_1614_4ece_2f7a_b0186e79adde --> e96f281e_f381_272d_2359_3e6a091c9a1d
  e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"]
  61433613_1614_4ece_2f7a_b0186e79adde --> e51fd0d2_bb38_cc97_7763_efe37f300a47
  6ec70299_8c45_d057_8deb_dd41bb1f7153["index.ts"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 6ec70299_8c45_d057_8deb_dd41bb1f7153
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 18a78965_f593_105b_e5e8_07001321c2ec
  1b971013_8a90_0d8d_1fcc_f31581cd66aa["Environment.ts"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 1b971013_8a90_0d8d_1fcc_f31581cd66aa
  3d8a23ee_d9c4_c61b_a642_c289a06d1a62["PartialEnvironmentConfig"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 3d8a23ee_d9c4_c61b_a642_c289a06d1a62
  494e3425_0b47_293a_1ea4_d4670b0fc0e7["Result.ts"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 494e3425_0b47_293a_1ea4_d4670b0fc0e7
  9217845a_d29d_c624_b607_e3b35cf604bc["Err"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 9217845a_d29d_c624_b607_e3b35cf604bc
  9f0e6a52_ff9e_00f3_1760_5fddfd89b234["Ok"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 9f0e6a52_ff9e_00f3_1760_5fddfd89b234
  7aace723_0ee1_cff5_b263_aec8e06dd79e["Result"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 7aace723_0ee1_cff5_b263_aec8e06dd79e
  eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"]
  61433613_1614_4ece_2f7a_b0186e79adde --> eb9d33f9_42c1_205c_93e6_8e1365a31839
  27d56ae1_023e_57f5_a306_f4be92e0daca["hasOwnProperty"]
  61433613_1614_4ece_2f7a_b0186e79adde --> 27d56ae1_023e_57f5_a306_f4be92e0daca
  d157601a_1234_7a9e_01ed_b9c8b76dc5e4["v4"]
  61433613_1614_4ece_2f7a_b0186e79adde --> d157601a_1234_7a9e_01ed_b9c8b76dc5e4
  2ed45bcd_6c82_3ccd_0e20_fa96b5111055[".."]
  61433613_1614_4ece_2f7a_b0186e79adde --> 2ed45bcd_6c82_3ccd_0e20_fa96b5111055
  style 61433613_1614_4ece_2f7a_b0186e79adde 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.
 */

import {fromZodError} from 'zod-validation-error/v4';
import {CompilerError} from '../CompilerError';
import {
  CompilationMode,
  defaultOptions,
  parsePluginOptions,
  PluginOptions,
} from '../Entrypoint';
import {EnvironmentConfig} from '..';
import {GeneratedSource} from '../HIR/HIR';
import {
  EnvironmentConfigSchema,
  PartialEnvironmentConfig,
} from '../HIR/Environment';
import {Err, Ok, Result} from './Result';
import {hasOwnProperty} from './utils';

function tryParseTestPragmaValue(val: string): Result<unknown, unknown> {
  try {
    let parsedVal: unknown;
    const stringMatch = /^"([^"]*)"$/.exec(val);
    if (stringMatch && stringMatch.length > 1) {
      parsedVal = stringMatch[1];
    } else {
      parsedVal = JSON.parse(val);
    }
    return Ok(parsedVal);
  } catch (e) {
    return Err(e);
  }
}

const testComplexConfigDefaults: PartialEnvironmentConfig = {
  validateNoCapitalizedCalls: [],
  enableChangeDetectionForDebugging: {
    source: 'react-compiler-runtime',
    importSpecifierName: '$structuralCheck',
  },
  enableEmitFreeze: {
    source: 'react-compiler-runtime',
    importSpecifierName: 'makeReadOnly',
  },
  enableEmitInstrumentForget: {
    fn: {
      source: 'react-compiler-runtime',
      importSpecifierName: 'useRenderCounter',
    },
    gating: {
      source: 'react-compiler-runtime',
      importSpecifierName: 'shouldInstrument',
    },
    globalGating: 'DEV',
  },
// ... (151 more lines)

Domain

Subdomains

Frequently Asked Questions

What does TestUtils.ts do?
TestUtils.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in TestUtils.ts?
TestUtils.ts defines 4 function(s): parseConfigPragmaEnvironmentForTest, parseConfigPragmaForTests, splitPragma, tryParseTestPragmaValue.
What does TestUtils.ts depend on?
TestUtils.ts imports 14 module(s): .., CompilerError, CompilerError.ts, Environment.ts, Err, HIR.ts, Ok, PartialEnvironmentConfig, and 6 more.
Where is TestUtils.ts in the architecture?
TestUtils.ts is located at compiler/packages/babel-plugin-react-compiler/src/Utils/TestUtils.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Utils).

Analyze Your Own Codebase

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

Try Supermodel Free