Home / File/ fixture-utils.ts — react Source File

fixture-utils.ts — react Source File

Architecture documentation for fixture-utils.ts, a typescript file in the react codebase. 4 imports, 4 dependents.

File typescript BabelCompiler Optimization 4 imports 4 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  4d76833e_f078_3b83_e453_82ab13e17c43["fixture-utils.ts"]
  dc3fd0be_e038_0596_3080_c93d9784f34e["constants.ts"]
  4d76833e_f078_3b83_e453_82ab13e17c43 --> dc3fd0be_e038_0596_3080_c93d9784f34e
  c0588312_ab09_8f72_8d9e_95868024d651["promises"]
  4d76833e_f078_3b83_e453_82ab13e17c43 --> c0588312_ab09_8f72_8d9e_95868024d651
  32b48cf9_1beb_1fdd_0f27_034d32523cc9["glob"]
  4d76833e_f078_3b83_e453_82ab13e17c43 --> 32b48cf9_1beb_1fdd_0f27_034d32523cc9
  b402a0fc_00db_e86d_b1ea_ad4f8e9faaca["path"]
  4d76833e_f078_3b83_e453_82ab13e17c43 --> b402a0fc_00db_e86d_b1ea_ad4f8e9faaca
  f294d5ab_dd3b_6bca_e120_e970909a7dc8["compiler.ts"]
  f294d5ab_dd3b_6bca_e120_e970909a7dc8 --> 4d76833e_f078_3b83_e453_82ab13e17c43
  3c2dde8c_5e90_a277_13bd_39083b18cadb["runner-watch.ts"]
  3c2dde8c_5e90_a277_13bd_39083b18cadb --> 4d76833e_f078_3b83_e453_82ab13e17c43
  49c99dfe_ec8f_3cb7_769b_a3b735b82b82["runner-worker.ts"]
  49c99dfe_ec8f_3cb7_769b_a3b735b82b82 --> 4d76833e_f078_3b83_e453_82ab13e17c43
  1fd49604_fb16_2568_4971_9eca12fd6a73["runner.ts"]
  1fd49604_fb16_2568_4971_9eca12fd6a73 --> 4d76833e_f078_3b83_e453_82ab13e17c43
  style 4d76833e_f078_3b83_e453_82ab13e17c43 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 fs from 'fs/promises';
import * as glob from 'glob';
import path from 'path';
import {FIXTURES_PATH, SNAPSHOT_EXTENSION} from './constants';

const INPUT_EXTENSIONS = [
  '.js',
  '.cjs',
  '.mjs',
  '.ts',
  '.cts',
  '.mts',
  '.jsx',
  '.tsx',
];

export type TestFilter = {
  paths: Array<string>;
};

function stripExtension(filename: string, extensions: Array<string>): string {
  for (const ext of extensions) {
    if (filename.endsWith(ext)) {
      return filename.slice(0, -ext.length);
    }
  }
  return filename;
}

export function getBasename(fixture: TestFixture): string {
  return stripExtension(path.basename(fixture.inputPath), INPUT_EXTENSIONS);
}
export function isExpectError(fixture: TestFixture | string): boolean {
  const basename = typeof fixture === 'string' ? fixture : getBasename(fixture);
  return basename.startsWith('error.') || basename.startsWith('todo.error');
}

export type TestFixture =
  | {
      fixturePath: string;
      input: string | null;
      inputPath: string;
      snapshot: string | null;
      snapshotPath: string;
    }
  | {
      fixturePath: string;
      input: null;
      inputPath: string;
      snapshot: string;
      snapshotPath: string;
    };

// ... (129 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does fixture-utils.ts do?
fixture-utils.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in fixture-utils.ts?
fixture-utils.ts defines 6 function(s): getBasename, getFixtures, isExpectError, readInputFixtures, readOutputFixtures, stripExtension.
What does fixture-utils.ts depend on?
fixture-utils.ts imports 4 module(s): constants.ts, glob, path, promises.
What files import fixture-utils.ts?
fixture-utils.ts is imported by 4 file(s): compiler.ts, runner-watch.ts, runner-worker.ts, runner.ts.
Where is fixture-utils.ts in the architecture?
fixture-utils.ts is located at compiler/packages/snap/src/fixture-utils.ts (domain: BabelCompiler, subdomain: Optimization, directory: compiler/packages/snap/src).

Analyze Your Own Codebase

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

Try Supermodel Free