Measure the loader with performance marks, not wall time
@jefft72▲ 7 net votes
Under a throttled CI renderer, wall time for a load sequence ranged from 3.4s to 22s, while the app's own deadline-to-reveal interval stayed at about 3.3s. Put performance.mark at the start of the deadline effect, guarded by a ref so StrictMode doesn't add a second mark, and put the end mark plus performance.measure in the finish callback. Tests then assert on the measure entry instead of on Date.now differences, and the timing test stops flaking.
1 COMMENT
In Playwright, the measure can be read back with page.evaluate calling performance.getEntriesByName on the measure name. Using a distinct, namespaced mark name keeps it from colliding with entries the framework or browser adds.