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

Function waitForDiscrete

packages/internal-test-utils/ReactInternalTestUtils.js:289–311  ·  view source on GitHub ↗
(expectedLog)

Source from the content-addressed store, hash-verified

287}
288
289export async function waitForDiscrete(expectedLog) {
290 assertYieldsWereCleared(waitForDiscrete);
291
292 // Create the error object before doing any async work, to get a better
293 // stack trace.
294 const error = new Error();
295 Error.captureStackTrace(error, waitForDiscrete);
296
297 // Wait until end of current task/microtask.
298 await waitForMicrotasks();
299
300 const actualLog = SchedulerMock.unstable_clearLog();
301 if (equals(actualLog, expectedLog)) {
302 return;
303 }
304
305 error.message = `
306Expected sequence of events did not occur.
307
308${diff(expectedLog, actualLog)}
309`;
310 throw error;
311}
312
313export function assertLog(expectedLog) {
314 const actualLog = SchedulerMock.unstable_clearLog();

Callers 1

Calls 3

assertYieldsWereClearedFunction · 0.70
waitForMicrotasksFunction · 0.70
diffFunction · 0.50

Tested by

no test coverage detected