MCPcopy
hub / github.com/facebook/react / readOutputFixtures

Function readOutputFixtures

compiler/packages/snap/src/fixture-utils.ts:141–175  ·  view source on GitHub ↗
(
  rootDir: string,
  filter: TestFilter | null,
)

Source from the content-addressed store, hash-verified

139 return new Map(await Promise.all(inputs));
140}
141async function readOutputFixtures(
142 rootDir: string,
143 filter: TestFilter | null,
144): Promise<Map<string, string>> {
145 let outputFiles: Array<string>;
146 if (filter == null) {
147 outputFiles = glob.sync(`**/*${SNAPSHOT_EXTENSION}`, {
148 cwd: rootDir,
149 });
150 } else {
151 outputFiles = (
152 await Promise.all(
153 filter.paths.map(pattern =>
154 glob.glob(`${pattern}${SNAPSHOT_EXTENSION}`, {
155 cwd: rootDir,
156 }),
157 ),
158 )
159 ).flat();
160 }
161 const outputs: Array<Promise<[string, string]>> = [];
162 for (const filePath of outputFiles) {
163 // Do not include extensions in unique identifier for fixture
164 const partialPath = stripExtension(filePath, [SNAPSHOT_EXTENSION]);
165
166 const outputPath = path.join(rootDir, filePath);
167 const output: Promise<[string, string]> = fs
168 .readFile(outputPath, 'utf8')
169 .then(output => {
170 return [partialPath, output];
171 });
172 outputs.push(output);
173 }
174 return new Map(await Promise.all(outputs));
175}
176
177export async function getFixtures(
178 filter: TestFilter | null,

Callers 1

getFixturesFunction · 0.85

Calls 5

stripExtensionFunction · 0.85
joinMethod · 0.80
mapMethod · 0.65
thenMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected