Skip to content

Commit 52c8214

Browse files
committed
fix: wait for two animation frames to prevent flaky test
The waitForAnimationFrame helper was only waiting for one animation frame, but due to the round-trip time of Playwright's page.evaluate, maquette's scheduled render could fire before our callback was registered. Waiting for two animation frames ensures maquette's render completes before the test continues.
1 parent fccbc33 commit 52c8214

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

browser-tests/tests/TodoPage.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ export class TodoPage {
3636
}
3737

3838
/**
39-
* Wait for one animation frame to allow maquette to render
39+
* Wait for two animation frames to allow maquette to render
4040
*/
4141
async waitForAnimationFrame(): Promise<void> {
4242
await this.page.evaluate(
43-
() => new Promise((resolve) => requestAnimationFrame(() => resolve(undefined)))
43+
() =>
44+
new Promise((resolve) =>
45+
requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined)))
46+
)
4447
);
4548
}
4649

0 commit comments

Comments
 (0)