Skip to content

Conversation

@johan-gorter
Copy link
Contributor

Fixes flaky test by waiting for two animation frames instead of one in waitForAnimationFrame helper. The round-trip time of Playwright's page.evaluate could cause maquette's render to fire before our callback was registered.

…ky test

Maquette only updates the DOM input value if it differs from the previous
render's value (to preserve cursor position). When fill() and press('Enter')
happen without an intervening render, this race condition occurs:

1. Initial render has value: '', previousValue = ''
2. fill() sets DOM value, schedules render
3. press('Enter') fires BEFORE animation frame
4. Handler clears newTodoTitle to ''
5. Render happens with value: ''
6. propValue ('') === previousValue (''), so DOM is NOT updated!

The fix adds a waitForAnimationFrame() after fill() to ensure maquette
renders the filled value before pressing Enter, so previousValue is updated.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a flaky test issue in the TodoMVC browser tests by modifying the waitForAnimationFrame() helper to wait for two animation frames instead of one. The change addresses a race condition where Playwright's page.evaluate() round-trip latency could cause maquette's render to fire before the callback was registered.

Changes:

  • Modified waitForAnimationFrame() to wait for two animation frames using nested requestAnimationFrame calls
  • Added a new wait before pressing Enter in addTodo() to ensure maquette renders the filled input value first
  • Updated comments to explain the timing requirements and clarify the purpose of each wait

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@jvanoostveen jvanoostveen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik zou eigenlijk verwachten dat die hele 'waitForAnimationFrame' niet nodig is, Playwright zou op zich retry-ability moeten toepassen?

@johan-gorter
Copy link
Contributor Author

Ik zou eigenlijk verwachten dat die hele 'waitForAnimationFrame' niet nodig is, Playwright zou op zich retry-ability moeten toepassen?

Klopt, maar zo waren de tests initieel niet opgezet, ze zijn letterlijk omgeschreven.

@johan-gorter johan-gorter merged commit d03374c into main Jan 15, 2026
3 checks passed
@johan-gorter johan-gorter deleted the fix-flaky-browser-test branch January 15, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants