I am trying to test an input value in my form, my form also contains a drop down list component – I keep getting the warning:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()? at label (/Users/HarrisM/apps/myrac-mobile/src/components/Dropdown/Dropdown.tsx:18:3)
How can I resolve the warning? My test is:
const mockedNavigation = {
goBack: jest.fn(),
navigate: jest.fn(),
setOptions: jest.fn(),
};
describe('Contact form test', () => {
const initialProps = {
navigation: mockedNavigation,
} as unknown as RegistrationRoutesGenericParams<'ContactSupportScreen'>;
test('should show email validation error', () => {
const rendered = render(
<MockedAppRootProvider>
<ContactSupportScreen {...initialProps} />
</MockedAppRootProvider>,
);
const enteredEmail = 'test@test';
const email = rendered.root.findByProps({
testID: 'email',
});
fireEvent.changeText(screen.getByTestId('email'), enteredEmail);
expect(email.props.style.color).toBe('#47474A');