migrate SafeAreaView from Jest to Fantom (#56310)

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

Migrate `SafeAreaView` from Jest to Fantom.

Note: SafeAreaView falls back to View in non-iOS environments, so `collapsable={false}` is needed to prevent Fantom from optimizing the view away.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D99290669

fbshipit-source-id: 8beaf75c4f8237e8f8955564799fed0bbf50d25a
This commit is contained in:
Emily Brown authored and meta-codesync[bot] committed 2026-04-09 03:33:11 -07:00
1 parent 05ea94c441
commit fd4fee0952
3 files changed
+38 -57

No files matched your search

@@ -0,0 +1,38 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {SafeAreaView, Text} from 'react-native';
describe('<SafeAreaView>', () => {
it('renders with children', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
// collapsable={false} is needed to prevent the View (SafeAreaView falls
// back to View in non-iOS environments) from being optimized away in
// the Fantom output.
<SafeAreaView collapsable={false}>
<Text>Hello World!</Text>
</SafeAreaView>,
);
});
expect(root.getRenderedOutput({props: []}).toJSX()).toEqual(
<rn-view>
<rn-paragraph>Hello World!</rn-paragraph>
</rn-view>,
);
});
});
@@ -1,36 +0,0 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
'use strict';
import SafeAreaView from '../SafeAreaView';
const Text = require('../../../Text/Text').default;
const ReactNativeTestTools = require('../../../Utilities/ReactNativeTestTools');
const View = require('../../View/View').default;
const React = require('react');
describe('<SafeAreaView />', () => {
it('should render as expected', async () => {
await ReactNativeTestTools.expectRendersMatchingSnapshot(
'SafeAreaView',
() => (
<SafeAreaView>
<View>
<Text>Hello World!</Text>
</View>
</SafeAreaView>
),
() => {
jest.dontMock('../SafeAreaView');
},
);
});
});
@@ -1,21 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<SafeAreaView /> should render as expected: should deep render when mocked (please verify output manually) 1`] = `
<RCTSafeAreaView>
<View>
<Text>
Hello World!
</Text>
</View>
</RCTSafeAreaView>
`;
exports[`<SafeAreaView /> should render as expected: should deep render when not mocked (please verify output manually) 1`] = `
<RCTSafeAreaView>
<View>
<Text>
Hello World!
</Text>
</View>
</RCTSafeAreaView>
`;