Home / Function/ readInputFixtures() — react Function Reference

readInputFixtures() — react Function Reference

Architecture documentation for the readInputFixtures() function in fixture-utils.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  c9fc6b7b_b3b4_2404_6749_1f817135b9e4["readInputFixtures()"]
  4d76833e_f078_3b83_e453_82ab13e17c43["fixture-utils.ts"]
  c9fc6b7b_b3b4_2404_6749_1f817135b9e4 -->|defined in| 4d76833e_f078_3b83_e453_82ab13e17c43
  35f5a65c_e6e8_8fa8_f9c0_158316bd8913["getFixtures()"]
  35f5a65c_e6e8_8fa8_f9c0_158316bd8913 -->|calls| c9fc6b7b_b3b4_2404_6749_1f817135b9e4
  06934a59_45ff_a607_9cdc_885425f09f00["stripExtension()"]
  c9fc6b7b_b3b4_2404_6749_1f817135b9e4 -->|calls| 06934a59_45ff_a607_9cdc_885425f09f00
  style c9fc6b7b_b3b4_2404_6749_1f817135b9e4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/snap/src/fixture-utils.ts lines 61–115

async function readInputFixtures(
  rootDir: string,
  filter: TestFilter | null,
): Promise<Map<string, {value: string; filepath: string}>> {
  let inputFiles: Array<string>;
  if (filter == null) {
    inputFiles = glob.sync(`**/*{${INPUT_EXTENSIONS.join(',')}}`, {
      cwd: rootDir,
    });
  } else {
    inputFiles = (
      await Promise.all(
        filter.paths.map(pattern => {
          // If the pattern already has an extension other than .expect.md,
          // search for the pattern directly. Otherwise, search for the
          // pattern with the expected input extensions added.
          // Eg
          // `alias-while` => search for `alias-while{.js,.jsx,.ts,.tsx}`
          // `alias-while.js` => search as-is
          // `alias-while.expect.md` => search for `alias-while{.js,.jsx,.ts,.tsx}`
          const patternWithoutExt = stripExtension(pattern, [
            ...INPUT_EXTENSIONS,
            SNAPSHOT_EXTENSION,
          ]);
          const hasExtension = pattern !== patternWithoutExt;
          const globPattern =
            hasExtension && !pattern.endsWith(SNAPSHOT_EXTENSION)
              ? pattern
              : `${patternWithoutExt}{${INPUT_EXTENSIONS.join(',')}}`;
          return glob.glob(globPattern, {
            cwd: rootDir,
          });
        }),
      )
    ).flat();
  }
  const inputs: Array<Promise<[string, {value: string; filepath: string}]>> =
    [];
  for (const filePath of inputFiles) {
    // Do not include extensions in unique identifier for fixture
    const partialPath = stripExtension(filePath, INPUT_EXTENSIONS);
    inputs.push(
      fs.readFile(path.join(rootDir, filePath), 'utf8').then(input => {
        return [
          partialPath,
          {
            value: input,
            filepath: filePath,
          },
        ];
      }),
    );
  }
  return new Map(await Promise.all(inputs));
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does readInputFixtures() do?
readInputFixtures() is a function in the react codebase, defined in compiler/packages/snap/src/fixture-utils.ts.
Where is readInputFixtures() defined?
readInputFixtures() is defined in compiler/packages/snap/src/fixture-utils.ts at line 61.
What does readInputFixtures() call?
readInputFixtures() calls 1 function(s): stripExtension.
What calls readInputFixtures()?
readInputFixtures() is called by 1 function(s): getFixtures.

Analyze Your Own Codebase

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

Try Supermodel Free