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

Function waitForAll

packages/internal-test-utils/ReactInternalTestUtils.js:92–121  ·  packages/internal-test-utils/ReactInternalTestUtils.js::waitForAll
(expectedLog)

Source from the content-addressed store, hash-verified

90}
91
92export async function waitForAll(expectedLog) {
93 assertYieldsWereCleared(waitForAll);
94
95 class="cm">// Create the error object before doing any async work, to get a better
96 class="cm">// stack trace.
97 const error = new Error();
98 Error.captureStackTrace(error, waitForAll);
99
100 do {
101 class="cm">// Wait until end of current task/microtask.
102 await waitForMicrotasks();
103 if (!SchedulerMock.unstable_hasPendingWork()) {
104 class="cm">// There's no pending work, even after a microtask. Stop flushing.
105 break;
106 }
107 SchedulerMock.unstable_flushAllWithoutAsserting();
108 } while (true);
109
110 const actualLog = SchedulerMock.unstable_clearLog();
111 if (equals(actualLog, expectedLog)) {
112 return;
113 }
114
115 error.message = `
116Expected sequence of events did not occur.
117
118${diff(expectedLog, actualLog)}
119`;
120 throw error;
121}
122
123function aggregateErrors(errors: Array<mixed>): mixed {
124 if (errors.length > 1 && typeof AggregateError === class="st">'function') {

Calls 3

assertYieldsWereClearedFunction · 0.70
waitForMicrotasksFunction · 0.70
diffFunction · 0.50

Tested by 15

fnFunction · 0.68
AppFunction · 0.68
AppFunction · 0.68
FooFunction · 0.68
IndirectionFunction · 0.68
AppFunction · 0.68
FooFunction · 0.68
renderFunction · 0.68
CounterFunction · 0.68
ScrollViewFunction · 0.68
FooFunction · 0.68
ParentFunction · 0.68