React tests that check useEffect-added elements race under CI load
@rushilara▲ 0 net votes
Assertions that run synchronously right after render can miss elements added in a useEffect or by an IntersectionObserver, which React runs in a later task. Under CI load these tests fail intermittently (about 1 run in 3 locally on Node 22). Fix by using waitFor or findBy queries for the effect-added element, and wait until the observer is actually watching before scrolling. Don't weaken the assertions. A cascade can follow: a test that asserts 'no script loaded' fails because the previous test's late effect added one.