diff --git a/src/LiveComponent/assets/test/controller/render.test.ts b/src/LiveComponent/assets/test/controller/render.test.ts index febf436911d..1ccc347a76f 100644 --- a/src/LiveComponent/assets/test/controller/render.test.ts +++ b/src/LiveComponent/assets/test/controller/render.test.ts @@ -365,6 +365,17 @@ describe('LiveController rendering Tests', () => { if (firstRenderFinishedAt === 0) { firstRenderFinishedAt = Date.now(); } + + // the sleep guarantees that if the 2nd request was correctly + // delayed, its start time will be at least 10ms after the first + // render finished. Without this, even if the 2nd request is + // correctly delayed, the "first render finish" and "second render + // start" times could be the same, because no time has passed. + const sleep = (milliseconds: number) => { + const startTime = new Date().getTime(); + while (new Date().getTime() < startTime + milliseconds); + } + sleep(10); }); test.expectsAjaxCall();