dillon1000/react
Commit
Browse files 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.
Changed paths6 files
First-parent comparisonpackages/internal-test-utils/ReactInternalTestUtils.js ModifiedA packages/internal-test-utils/enqueueTask.js AddedM packages/react-cache/src/__tests__/ReactCacheOld-test.internal.js ModifiedM packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js ModifiedM packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js ModifiedM packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…