From f05d79be2424067e34d9cbeaeaf3cd43945a20b5 Mon Sep 17 00:00:00 2001 From: Abbey Campbell Date: Tue, 9 Dec 2025 18:30:25 -0800 Subject: [PATCH] remove isTest flag, override bottom-tabs animation in jest setup, add comments to detox fix --- e2e/sharedFlows/switchPowerMode.js | 2 ++ src/navigation/BottomTabNavigator/index.tsx | 6 +----- tests/jest.setup.js | 24 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/e2e/sharedFlows/switchPowerMode.js b/e2e/sharedFlows/switchPowerMode.js index fc9ef91d6..6f1940a30 100644 --- a/e2e/sharedFlows/switchPowerMode.js +++ b/e2e/sharedFlows/switchPowerMode.js @@ -7,6 +7,8 @@ const TIMEOUT = 10_000; export default async function switchPowerMode() { const menuButton = element( by.id( "OPEN_MENU" ) ); + // Temporarily disable synchronization to work around fade animation timing + // issues that can cause Detox to wait indefinitely for animations to complete await device.disableSynchronization(); await waitFor( menuButton ).toBeVisible().withTimeout( TIMEOUT ); await menuButton.tap( { x: 0, y: 0 } ); diff --git a/src/navigation/BottomTabNavigator/index.tsx b/src/navigation/BottomTabNavigator/index.tsx index fbf83c2b0..d2949fc9e 100644 --- a/src/navigation/BottomTabNavigator/index.tsx +++ b/src/navigation/BottomTabNavigator/index.tsx @@ -18,8 +18,6 @@ const Tab = createBottomTabNavigator( ); const BottomTabs = ( ) => { const renderTabBar = ( props: BottomTabBarProps ) => ; - const isTest = process.env.JEST_WORKER_ID !== undefined; - // DEVELOPERS: do you need to add any screens here? All the rest of our screens live in // NoBottomTabStackNavigator, TabStackNavigator, or LoginStackNavigator @@ -33,9 +31,7 @@ const BottomTabs = ( ) => { lazy: true, freezeOnBlur: true, headerShown: false, - animation: isTest - ? "none" - : "fade" + animation: "fade" }} > { return jest.fn( ( ) => React.createElement( View, null ) ); } ); +// Mock @react-navigation/bottom-tabs to disable animations in Jest tests +// This prevents the act() warnings caused by fade animations triggering state updates +jest.mock( "@react-navigation/bottom-tabs", () => { + const React = require( "react" ); + const actual = jest.requireActual( "@react-navigation/bottom-tabs" ); + const createBottomTabNavigator = () => { + const Tab = actual.createBottomTabNavigator(); + const OriginalNavigator = Tab.Navigator; + Tab.Navigator = function Navigator( props ) { + const { screenOptions, ...restProps } = props; + // Override animation to "none" for both function and object screenOptions + const modifiedScreenOptions = typeof screenOptions === "function" + ? route => ( { ...screenOptions( route ), animation: "none" } ) + : { ...screenOptions, animation: "none" }; + return React.createElement( + OriginalNavigator, + { ...restProps, screenOptions: modifiedScreenOptions } + ); + }; + return Tab; + }; + return { ...actual, createBottomTabNavigator }; +} ); + // this silences console methods in jest tests, to make them less noisy // and easier to debug. uncomment if you want to silence them global.console = {