Home / Function/ waitForAll() — react Function Reference

waitForAll() — react Function Reference

Architecture documentation for the waitForAll() function in ReactInternalTestUtils.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  b768b645_4318_ed74_0967_a42b9ae871bf["waitForAll()"]
  29c464eb_52d1_465c_432a_544e82213726["ReactInternalTestUtils.js"]
  b768b645_4318_ed74_0967_a42b9ae871bf -->|defined in| 29c464eb_52d1_465c_432a_544e82213726
  649f12be_3313_b4be_bac2_9cdf587b5e58["assertYieldsWereCleared()"]
  b768b645_4318_ed74_0967_a42b9ae871bf -->|calls| 649f12be_3313_b4be_bac2_9cdf587b5e58
  a171b128_18a5_9e04_9a7e_e896f8e81a4b["waitForMicrotasks()"]
  b768b645_4318_ed74_0967_a42b9ae871bf -->|calls| a171b128_18a5_9e04_9a7e_e896f8e81a4b
  style b768b645_4318_ed74_0967_a42b9ae871bf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/internal-test-utils/ReactInternalTestUtils.js lines 92–121

export async function waitForAll(expectedLog) {
  assertYieldsWereCleared(waitForAll);

  // Create the error object before doing any async work, to get a better
  // stack trace.
  const error = new Error();
  Error.captureStackTrace(error, waitForAll);

  do {
    // Wait until end of current task/microtask.
    await waitForMicrotasks();
    if (!SchedulerMock.unstable_hasPendingWork()) {
      // There's no pending work, even after a microtask. Stop flushing.
      break;
    }
    SchedulerMock.unstable_flushAllWithoutAsserting();
  } while (true);

  const actualLog = SchedulerMock.unstable_clearLog();
  if (equals(actualLog, expectedLog)) {
    return;
  }

  error.message = `
Expected sequence of events did not occur.

${diff(expectedLog, actualLog)}
`;
  throw error;
}

Domain

Subdomains

Frequently Asked Questions

What does waitForAll() do?
waitForAll() is a function in the react codebase, defined in packages/internal-test-utils/ReactInternalTestUtils.js.
Where is waitForAll() defined?
waitForAll() is defined in packages/internal-test-utils/ReactInternalTestUtils.js at line 92.
What does waitForAll() call?
waitForAll() calls 2 function(s): assertYieldsWereCleared, waitForMicrotasks.

Analyze Your Own Codebase

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

Try Supermodel Free