import { render } from '@testing-library/react-native'; import * as React from 'react'; import * as UsePressable from '../hooks/usePressable'; import { Pressable, PressableProps } from './Pressable'; afterEach(() => { jest.clearAllMocks(); }); describe('Pressable', () => { it('uses the usePressable hook', () => { const test = { style: { backgroundColor: 'yellow' }, another: 'property', }; const spy = jest .spyOn(UsePressable, 'usePressable') .mockReturnValue(test as any); const props: Partial = { accessibilityRole: 'button', accessibilityLabel: 'hello', testID: 'test-id', style: { backgroundColor: 'red', width: 42, }, }; const renderAPI = renderPressable(props as any); expect(spy).toHaveBeenCalledWith(props, expect.anything()); expect(renderAPI.toJSON()).toMatchInlineSnapshot(` `); }); }); function renderPressable(props: PressableProps) { return render( <> , ); } jest.mock('../hooks/usePressable');