SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

Fix flaky Modal-itest by adding proper root cleanup (#55712)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55712

changelog: [Internal]

The Modal tests are flaky because message queue is sometimes not empty, leading to error: "MessageQueue is not empty".

The fix adds beforeEach/afterEach hooks to create a fresh root for each test and properly destroy it afterwards. The root.destroy() call flushes the message queue, ensuring cleanup happens before the next test.

I am not 100% sure why this happens, especially in multithreading environment. But this makes the situation less bad and tests less flaky. It does not address the root cause.

Reviewed By: cipolleschi

Differential Revision: D92171933

fbshipit-source-id: 0b931771475c9b65fe287ab06d1652d7d5d7efab
S
Samuel Susla committed
2c65dd7c701dad7ba5f34328d95c93a0527170cf
Parent: 938a338
Committed by Nicola Corti <[email protected]> on 2/27/2026, 4:33:39 PM