Skip to content

Commit 46d73bf

Browse files
alanleedevfacebook-github-bot
authored andcommitted
Fix Modal Fantom test (#54811)
Summary: Test was failing in CI with following error: ``` Summary of all failing tests FAIL packages/react-native/Libraries/Modal/__tests__/Modal-itest.js (5.619 s) ● <Modal> (hermes) › props › presentationStyle › renders a Modal with presentationStyle="pageSheet" Exception in HostFunction: MessageQueue is not empty at validateEmptyMessageQueue (native) 417 | require('react-native/src/private/testing/fantom/specs/NativeFantom').default; 418 | > 419 | NativeFantom.validateEmptyMessageQueue(); | ^ 420 | } 421 | 422 | function serializeError(error: Error): FailureDetail { at validateEmptyMessageQueue (private/react-native-fantom/runtime/setup.js:419:41) at invokeHooks (private/react-native-fantom/runtime/setup.js:286:11) at spec (private/react-native-fantom/runtime/setup.js:336:16) at suite (private/react-native-fantom/runtime/setup.js:390:20) at child (private/react-native-fantom/runtime/setup.js:374:33) at suite (private/react-native-fantom/runtime/setup.js:388:22) at child (private/react-native-fantom/runtime/setup.js:374:33) at suite (private/react-native-fantom/runtime/setup.js:388:22) at child (private/react-native-fantom/runtime/setup.js:374:33) at suite (private/react-native-fantom/runtime/setup.js:388:22) at child (private/react-native-fantom/runtime/setup.js:374:33) at suite (private/react-native-fantom/runtime/setup.js:388:22) at currentContext (private/react-native-fantom/runtime/setup.js:436:20) at anonymous (private/react-native-fantom/runtime/setup.js:470:27) ``` The Modal Fantom test was failing in CI with "MessageQueue is not empty" error. Referencing other tests, added afterEach() to call `root.destroy()` for proper cleanup after each test. Changelog: [Internal] Fix Fantom test Differential Revision: D88538595
1 parent 602a2d2 commit 46d73bf

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

packages/react-native/Libraries/Modal/__tests__/Modal-itest.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ const DEFAULT_MODAL_CHILD_VIEW = (
2828
);
2929

3030
describe('<Modal>', () => {
31+
let root: Fantom.Root;
32+
33+
afterEach(() => {
34+
root.destroy();
35+
});
36+
3137
describe('props', () => {
3238
it('renders a Modal with the default values when no props are passed', () => {
33-
const root = Fantom.createRoot();
39+
root = Fantom.createRoot();
3440

3541
Fantom.runTask(() => {
3642
root.render(<Modal />);
@@ -44,7 +50,7 @@ describe('<Modal>', () => {
4450
});
4551
describe('animationType', () => {
4652
it('renders a Modal with animationType="none" by default', () => {
47-
const root = Fantom.createRoot();
53+
root = Fantom.createRoot();
4854

4955
Fantom.runTask(() => {
5056
root.render(<Modal animationType="none" />);
@@ -61,7 +67,7 @@ describe('<Modal>', () => {
6167

6268
(['slide', 'fade'] as const).forEach(animationType => {
6369
it(`renders a Modal with animationType="${animationType}"`, () => {
64-
const root = Fantom.createRoot();
70+
root = Fantom.createRoot();
6571

6672
Fantom.runTask(() => {
6773
root.render(<Modal animationType={animationType} />);
@@ -80,7 +86,7 @@ describe('<Modal>', () => {
8086

8187
describe('presentationStyle', () => {
8288
it('renders a Modal with presentationStyle="fullScreen" by default', () => {
83-
const root = Fantom.createRoot();
89+
root = Fantom.createRoot();
8490

8591
Fantom.runTask(() => {
8692
root.render(<Modal presentationStyle="fullScreen" />);
@@ -98,7 +104,7 @@ describe('<Modal>', () => {
98104
(['pageSheet', 'formSheet', 'overFullScreen'] as const).forEach(
99105
presentationStyle => {
100106
it(`renders a Modal with presentationStyle="${presentationStyle}"`, () => {
101-
const root = Fantom.createRoot();
107+
root = Fantom.createRoot();
102108

103109
Fantom.runTask(() => {
104110
root.render(<Modal presentationStyle={presentationStyle} />);
@@ -117,7 +123,7 @@ describe('<Modal>', () => {
117123
});
118124
describe('transparent', () => {
119125
it('renders a Modal with transparent="true"', () => {
120-
const root = Fantom.createRoot();
126+
root = Fantom.createRoot();
121127

122128
Fantom.runTask(() => {
123129
root.render(<Modal transparent={true} />);
@@ -137,7 +143,7 @@ describe('<Modal>', () => {
137143
});
138144

139145
it('renders a Modal with transparent="false"', () => {
140-
const root = Fantom.createRoot();
146+
root = Fantom.createRoot();
141147

142148
Fantom.runTask(() => {
143149
root.render(<Modal transparent={false} />);
@@ -156,7 +162,7 @@ describe('<Modal>', () => {
156162
});
157163
describe('statusBarTranslucent', () => {
158164
it('renders a Modal with statusBarTranslucent="true"', () => {
159-
const root = Fantom.createRoot();
165+
root = Fantom.createRoot();
160166

161167
Fantom.runTask(() => {
162168
root.render(<Modal statusBarTranslucent={true} />);
@@ -171,7 +177,7 @@ describe('<Modal>', () => {
171177
);
172178
});
173179
it('renders a Modal with statusBarTranslucent="false"', () => {
174-
const root = Fantom.createRoot();
180+
root = Fantom.createRoot();
175181

176182
Fantom.runTask(() => {
177183
root.render(<Modal statusBarTranslucent={false} />);
@@ -188,7 +194,7 @@ describe('<Modal>', () => {
188194
});
189195
describe('navigationBarTranslucent', () => {
190196
it('renders a Modal with navigationBarTranslucent="true" and statusBarTranslucent="true"', () => {
191-
const root = Fantom.createRoot();
197+
root = Fantom.createRoot();
192198

193199
Fantom.runTask(() => {
194200
// navigationBarTranslucent=true with statusBarTranslucent=false is not supported
@@ -216,7 +222,7 @@ describe('<Modal>', () => {
216222
);
217223
});
218224
it('renders a Modal with navigationBarTranslucent="false"', () => {
219-
const root = Fantom.createRoot();
225+
root = Fantom.createRoot();
220226

221227
Fantom.runTask(() => {
222228
root.render(<Modal navigationBarTranslucent={false} />);
@@ -238,7 +244,7 @@ describe('<Modal>', () => {
238244

239245
describe('hardwareAccelerated', () => {
240246
it('renders a Modal with hardwareAccelerated="true"', () => {
241-
const root = Fantom.createRoot();
247+
root = Fantom.createRoot();
242248

243249
Fantom.runTask(() => {
244250
root.render(<Modal hardwareAccelerated={true} />);
@@ -253,7 +259,7 @@ describe('<Modal>', () => {
253259
);
254260
});
255261
it('renders a Modal with hardwareAccelerated="false"', () => {
256-
const root = Fantom.createRoot();
262+
root = Fantom.createRoot();
257263

258264
Fantom.runTask(() => {
259265
root.render(<Modal hardwareAccelerated={false} />);
@@ -271,7 +277,7 @@ describe('<Modal>', () => {
271277

272278
describe('visible', () => {
273279
it('renders a Modal with visible="true"', () => {
274-
const root = Fantom.createRoot();
280+
root = Fantom.createRoot();
275281

276282
Fantom.runTask(() => {
277283
root.render(<Modal visible={true} />);
@@ -283,8 +289,9 @@ describe('<Modal>', () => {
283289
</rn-modalHostView>,
284290
);
285291
});
292+
286293
it('renders nothing when visible="false"', () => {
287-
const root = Fantom.createRoot();
294+
root = Fantom.createRoot();
288295

289296
Fantom.runTask(() => {
290297
root.render(<Modal visible={false} />);
@@ -296,7 +303,7 @@ describe('<Modal>', () => {
296303

297304
describe('allowSwipeDismissal', () => {
298305
it('renders a Modal with allowSwipeDismissal="true"', () => {
299-
const root = Fantom.createRoot();
306+
root = Fantom.createRoot();
300307

301308
Fantom.runTask(() => {
302309
root.render(<Modal allowSwipeDismissal={true} />);
@@ -311,7 +318,7 @@ describe('<Modal>', () => {
311318
);
312319
});
313320
it('renders a Modal with allowSwipeDismissal="false"', () => {
314-
const root = Fantom.createRoot();
321+
root = Fantom.createRoot();
315322

316323
Fantom.runTask(() => {
317324
root.render(<Modal allowSwipeDismissal={false} />);
@@ -332,7 +339,7 @@ describe('<Modal>', () => {
332339
// The 'animated' prop is deprecated and ignored when the Modal is rendered
333340
// Users should use the 'animationType' prop instead.
334341
it(`[DEPRECATED] renders a Modal with animated="${animated ? 'true' : 'false'}"`, () => {
335-
const root = Fantom.createRoot();
342+
root = Fantom.createRoot();
336343

337344
Fantom.runTask(() => {
338345
root.render(<Modal animated={animated} />);
@@ -356,7 +363,8 @@ describe('<Modal>', () => {
356363
describe('instance', () => {
357364
it('uses the "RN:ModalHostView" tag name', () => {
358365
const elementRef = createRef<HostInstance>();
359-
const root = Fantom.createRoot();
366+
root = Fantom.createRoot();
367+
360368
Fantom.runTask(() => {
361369
root.render(<Modal ref={elementRef} />);
362370
});

0 commit comments

Comments
 (0)