remove isTest flag, override bottom-tabs animation in jest setup, add comments to detox fix

This commit is contained in:
Abbey Campbell
2025-12-09 18:30:25 -08:00
parent 1d2d992cbb
commit f05d79be24
3 changed files with 27 additions and 5 deletions

View File

@@ -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 } );

View File

@@ -18,8 +18,6 @@ const Tab = createBottomTabNavigator( );
const BottomTabs = ( ) => {
const renderTabBar = ( props: BottomTabBarProps ) => <CustomTabBarContainer {...props} />;
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"
}}
>
<Tab.Screen

View File

@@ -175,6 +175,30 @@ jest.mock( "components/Camera/FadeInOutView", () => {
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 = {