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

Function runFixtures

compiler/packages/snap/src/runner.ts:72–115  ·  view source on GitHub ↗

* Do a test run and return the test results

(
  worker: Worker & typeof runnerWorker,
  filter: TestFilter | null,
  compilerVersion: number,
)

Source from the content-addressed store, hash-verified

70 * Do a test run and return the test results
71 */
72async function runFixtures(
73 worker: Worker & typeof runnerWorker,
74 filter: TestFilter | null,
75 compilerVersion: number,
76): Promise<TestResults> {
77 // We could in theory be fancy about tracking the contents of the fixtures
78 // directory via our file subscription, but it's simpler to just re-read
79 // the directory each time.
80 const fixtures = await getFixtures(filter);
81 const isOnlyFixture = filter !== null && fixtures.size === 1;
82
83 let entries: Array<[string, TestResult]>;
84 if (!opts.sync) {
85 // Note: promise.all to ensure parallelism when enabled
86 const work: Array<Promise<[string, TestResult]>> = [];
87 for (const [fixtureName, fixture] of fixtures) {
88 work.push(
89 worker
90 .transformFixture(
91 fixture,
92 compilerVersion,
93 (filter?.debug ?? false) && isOnlyFixture,
94 true,
95 )
96 .then(result => [fixtureName, result]),
97 );
98 }
99
100 entries = await Promise.all(work);
101 } else {
102 entries = [];
103 for (const [fixtureName, fixture] of fixtures) {
104 let output = await runnerWorker.transformFixture(
105 fixture,
106 compilerVersion,
107 (filter?.debug ?? false) && isOnlyFixture,
108 true,
109 );
110 entries.push([fixtureName, output]);
111 }
112 }
113
114 return new Map(entries);
115}
116
117// Callback to re-run tests after some change
118async function onChange(

Callers 2

onChangeFunction · 0.85
mainFunction · 0.85

Calls 3

getFixturesFunction · 0.90
pushMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected