SIGN IN SIGN UP
facebook / react UNCLAIMED

The library for web and native user interfaces.

244379 0 0 JavaScript

Convert ReactLazy-test to waitFor pattern (#26304)

I'm in the process of codemodding our test suite to the waitFor pattern.
See #26285 for full context.

This module required a lot of manual changes so I'm doing it as its own
PR. The reason is that most of the tests involved simulating an async
import by wrapping them in `Promise.resolve()`, which means they would
immediately resolve the next time the microtask queue was flushed. I
rewrote the tests to resolve the simulated import explicitly.

While converting these tests, I also realized that the `waitFor` helpers
weren't properly waiting for the entire microtask queue to recursively
finish — if a microtask schedules another microtask, the subsequent one
wouldn't fire until after `waitFor` had resolved. To fix this, I used
the same strategy as `act` — wait for a real task to finish before
proceeding, such as a message event.
A
Andrew Clark committed
9a52cc8bcd580238f4a8b12036e698823847fd65
Parent: 03462cf
Committed by GitHub <noreply@github.com> on 3/4/2023, 4:44:41 PM