diff --git a/packages/react-native/Libraries/Modal/__tests__/Modal-itest.js b/packages/react-native/Libraries/Modal/__tests__/Modal-itest.js index 30ed74e0c2b2..ee63065de78c 100644 --- a/packages/react-native/Libraries/Modal/__tests__/Modal-itest.js +++ b/packages/react-native/Libraries/Modal/__tests__/Modal-itest.js @@ -28,18 +28,22 @@ const DEFAULT_MODAL_CHILD_VIEW = ( ); describe('', () => { + let root: Fantom.Root; + + beforeEach(() => { + root = Fantom.createRoot(); + }); + afterEach(() => { + root.destroy(); // Flush any remaining tasks that may have been scheduled during the // render (e.g. passive effects from AppContainer in __DEV__ mode). // This prevents flaky "MessageQueue is not empty" failures from the // global afterEach validation hook. Fantom.runWorkLoop(); }); - describe('props', () => { it('renders a Modal with the default values when no props are passed', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -52,8 +56,6 @@ describe('', () => { }); describe('animationType', () => { it('renders a Modal with animationType="none" by default', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -69,8 +71,6 @@ describe('', () => { (['slide', 'fade'] as const).forEach(animationType => { it(`renders a Modal with animationType="${animationType}"`, () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -88,8 +88,6 @@ describe('', () => { describe('presentationStyle', () => { it('renders a Modal with presentationStyle="fullScreen" by default', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -106,8 +104,6 @@ describe('', () => { (['pageSheet', 'formSheet', 'overFullScreen'] as const).forEach( presentationStyle => { it(`renders a Modal with presentationStyle="${presentationStyle}"`, () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -125,8 +121,6 @@ describe('', () => { }); describe('transparent', () => { it('renders a Modal with transparent="true"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -145,8 +139,6 @@ describe('', () => { }); it('renders a Modal with transparent="false"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -164,8 +156,6 @@ describe('', () => { }); describe('statusBarTranslucent', () => { it('renders a Modal with statusBarTranslucent="true"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -179,8 +169,6 @@ describe('', () => { ); }); it('renders a Modal with statusBarTranslucent="false"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -196,8 +184,6 @@ describe('', () => { }); describe('navigationBarTranslucent', () => { it('renders a Modal with navigationBarTranslucent="true" and statusBarTranslucent="true"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { // navigationBarTranslucent=true with statusBarTranslucent=false is not supported // and it emits a warning. @@ -224,8 +210,6 @@ describe('', () => { ); }); it('renders a Modal with navigationBarTranslucent="false"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -246,8 +230,6 @@ describe('', () => { describe('hardwareAccelerated', () => { it('renders a Modal with hardwareAccelerated="true"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -261,8 +243,6 @@ describe('', () => { ); }); it('renders a Modal with hardwareAccelerated="false"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -279,8 +259,6 @@ describe('', () => { describe('visible', () => { it('renders a Modal with visible="true"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -292,8 +270,6 @@ describe('', () => { ); }); it('renders nothing when visible="false"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -304,8 +280,6 @@ describe('', () => { describe('allowSwipeDismissal', () => { it('renders a Modal with allowSwipeDismissal="true"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -319,8 +293,6 @@ describe('', () => { ); }); it('renders a Modal with allowSwipeDismissal="false"', () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -340,8 +312,6 @@ describe('', () => { // The 'animated' prop is deprecated and ignored when the Modal is rendered // Users should use the 'animationType' prop instead. it(`[DEPRECATED] renders a Modal with animated="${animated ? 'true' : 'false'}"`, () => { - const root = Fantom.createRoot(); - Fantom.runTask(() => { root.render(); }); @@ -364,7 +334,6 @@ describe('', () => { describe('instance', () => { it('uses the "RN:ModalHostView" tag name', () => { const elementRef = createRef(); - const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); });