Skip to content

Migrate Core, BatchedBridge, and feature-flag Jest tests to Fantom#57263

Closed
rubennorte wants to merge 7 commits into
react:mainfrom
rubennorte:export-D108759080
Closed

Migrate Core, BatchedBridge, and feature-flag Jest tests to Fantom#57263
rubennorte wants to merge 7 commits into
react:mainfrom
rubennorte:export-D108759080

Conversation

@rubennorte

Copy link
Copy Markdown
Contributor

Summary:
Migrates runtime infrastructure unit tests from regular Jest (-test.js) to Fantom (-itest.js): parseErrorStack, parseHermesStack, ReactNativeVersionCheck, ReactNativeAttributePayload, MessageQueue, TracingStateObserver, and the JS-only portion of ReactNativeFeatureFlags.

ReactNativeFeatureFlags is split: the JS-only cases moved to Fantom, while four cases that assert on the native feature-flag spec (which require module mocking) remain in the Jest file for now.

Several tests remain on Jest because they fundamentally depend on capabilities Fantom does not provide (module mocks and/or jest fake timers): ExceptionsManager, loadBundleFromServer, JSTimers, NativeModules, and FabricUIManager.

Changelog: [Internal]

Differential Revision: D108759080

rubennorte and others added 7 commits June 18, 2026 02:36
Summary:
Migrates the pure-logic StyleSheet unit tests from regular Jest (`-test.js`) to Fantom (`-itest.js`), so they run on Hermes inside the real React Native runtime, the same engine that runs this code in production.

Migrated files (all style-processing utilities that run on the client at runtime): `flattenStyle`, `processAspectRatio`, `processBackgroundPosition`, `processBackgroundRepeat`, `processBackgroundSize`, `processFilter`, `processFontVariant`, `processTransform`, `processTransformOrigin`, `setNormalizedColorAlpha`, `splitLayoutProps`.

Notable adaptations:
- `toThrowErrorMatchingSnapshot()` and `toThrowErrorMatchingInlineSnapshot()` are not available in Fantom, so they were replaced with `toThrow('<exact message>')`, preserving the exact error messages that were previously captured in snapshots.
- Removed the now-obsolete file snapshots for `processAspectRatio`, `processTransform`, and `processTransformOrigin`.
- `toMatchInlineSnapshot` (used by `splitLayoutProps`) is supported by Fantom and was kept unchanged.

Changelog: [Internal]

Differential Revision: D108759084
Summary:
Migrates the remaining StyleSheet unit tests from regular Jest (`-test.js`) to Fantom (`-itest.js`): `normalizeColor`, `processColor`, `processColorArray`, `processBackgroundImage`, and `StyleSheet`. These run on the React Native client at runtime, so they now run on Hermes in the real runtime.

Adaptations (no coverage weakened):
- Replaced `jest.spyOn(console, ...)` with manual save/replace/restore of the `console` method (Fantom does not provide `jest.spyOn`), both to assert and to suppress expected output.
- Replaced the module-mock delegation check in `normalizeColor` (which relied on `jest.mock`) with a behavioral assertion on the real implementation.
- These tests run on the Android runtime under Fantom (Jest defaulted to iOS); platform-specific requires were moved next to their platform branches where needed.

Changelog: [Internal]

Differential Revision: D108759085
Summary:
Migrates 17 unit tests from regular Jest (`-test.js`) to Fantom (`-itest.js`) under `Libraries/Utilities` (and `Libraries/Utilities/differ`) and `Libraries/vendor/emitter`, so this runtime client code is tested on Hermes in the real React Native runtime.

Migrated: `binaryToBase64`, `deepFreezeAndThrowOnMutationInDev`, `DeviceInfo`, `Dimensions`, `logError`, `mapWithSeparator`, `PixelRatio`, `Platform`, `SceneTracker`, `stringifySafe`, `useColorScheme`, `useMergeRefs`, `useRefEffect`, `warnOnce`, `differ/deepDiffer`, `differ/matricesDiffer`, and `EventEmitter`.

Adaptations (no behavioral coverage weakened):
- Replaced `jest.spyOn(console, ...)` with manual save/replace/restore capture of the `console` method.
- Replaced hook/component tests that used `react-test-renderer` with Fantom rendering (`createRoot` + `runTask`), reading hook return values via a small probe component and ref identity via `ensureInstance`.
- Adapted a few expected values to the real Hermes/Android runtime (e.g. function `toString` output, `useColorScheme` returning null when native Appearance is unavailable).
- Replaced node-only `TextEncoder`/`TextDecoder` usage in `binaryToBase64` with explicit byte construction.

Two tests intentionally remain on Jest because they cannot be expressed without module mocking / the test-renderer tree API (both unsupported by Fantom): `codegenNativeComponent` (mocks native component registration) and `ReactNativeTestTools` (tests jest helpers built on the `react-test-renderer` instance tree).

Changelog: [Internal]

Differential Revision: D108759079
Summary:
Migrates 10 Animated unit tests from regular Jest (`-test.js`) to Fantom (`-itest.js`) so they run on Hermes in the real React Native runtime.

Migrated: `Easing`, `bezier`, `Interpolation`, `AnimatedObject`, `AnimatedValue`, `AnimatedMock`, `TimingAnimation`, `createAnimatedPropsHook`, `createAnimatedPropsMemoHook`. The two `Libraries/Animated/nodes/AnimatedProps` cases were folded into the existing `AnimatedProps-itest.js` (importing the same module), with no loss of coverage.

Adaptations (no behavioral coverage weakened):
- Drove animation timing with Fantom scheduling instead of jest fake timers, and asserted against the real native animated backend rather than mocking it.
- Replaced `react-test-renderer` rendering with Fantom `createRoot` + `runTask`, asserting real Fabric output / element refs.

Four Animated tests intentionally remain on Jest because they depend on capabilities Fantom does not provide (jest fake timers and/or module mocks of the native animated module): `Animated`, `Animated-web`, `AnimatedNative`, and `NativeAnimatedAllowlist`.

Changelog: [Internal]

Differential Revision: D108759083
Summary:
Migrates component unit tests from regular Jest (`-test.js`) to Fantom (`-itest.js`) so they render through the real React Native runtime (Fabric/Yoga) instead of a mocked renderer.

Folded missing cases into existing Fantom tests (`View`, `ScrollView`, `Pressable`, `ActivityIndicator`, `Button`, `TouchableOpacity`, `TouchableWithoutFeedback`, `Modal`, `FlatList`) and added new Fantom tests for `TouchableNativeFeedback` and `InputAccessoryView`. Obsolete file snapshots that captured the old mocked output were removed; assertions now compare against the real Fabric output.

A few component tests remain on Jest for now because they depend on capabilities Fantom does not provide (module mocks of native modules / mock-based event simulation): `AccessibilityInfo`, `DrawerAndroid`, `Keyboard`, `StatusBar`, and `Pressability`.

Changelog: [Internal]

Differential Revision: D108759082
Summary:
Migrates `Image`, `Text`, and `NativeComponent` unit tests from regular Jest (`-test.js`) to Fantom (`-itest.js`).

Folded missing cases into the existing `Image`, `ImageBackground`, and `Text` Fantom tests (asserting real Fabric output such as `rn-image`/`rn-paragraph` instead of the previously mocked `RCTImageView`/`RCTText`), and migrated the pure-logic helpers `AssetUtils`, `ImageSourceUtils`, `assetRelativePathInSnapshot`, and `StaticViewConfigValidator`. Obsolete mocked-output snapshots were removed.

`resolveAssetSource` remains on Jest because it relies on `jest.resetModules` to reset module-level state between cases, which Fantom does not support.

Changelog: [Internal]

Differential Revision: D108759081
Summary:
Migrates runtime infrastructure unit tests from regular Jest (`-test.js`) to Fantom (`-itest.js`): `parseErrorStack`, `parseHermesStack`, `ReactNativeVersionCheck`, `ReactNativeAttributePayload`, `MessageQueue`, `TracingStateObserver`, and the JS-only portion of `ReactNativeFeatureFlags`.

`ReactNativeFeatureFlags` is split: the JS-only cases moved to Fantom, while four cases that assert on the native feature-flag spec (which require module mocking) remain in the Jest file for now.

Several tests remain on Jest because they fundamentally depend on capabilities Fantom does not provide (module mocks and/or jest fake timers): `ExceptionsManager`, `loadBundleFromServer`, `JSTimers`, `NativeModules`, and `FabricUIManager`.

Changelog: [Internal]

Differential Revision: D108759080
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2026
@meta-codesync

meta-codesync Bot commented Jun 18, 2026

Copy link
Copy Markdown

@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108759080.

@meta-codesync

meta-codesync Bot commented Jun 18, 2026

Copy link
Copy Markdown

This pull request has been merged in 4dfbc04.

@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant