From e736ecf0dfebfe26ab8d94815b6e206133d531b9 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Thu, 24 Jun 2021 17:32:11 +0200 Subject: [PATCH] Mock switch component to address a warning --- test/native/setup.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/native/setup.js b/test/native/setup.js index 2df7fb1889b293..a3e0561024b341 100644 --- a/test/native/setup.js +++ b/test/native/setup.js @@ -178,3 +178,14 @@ jest.mock( } ) ), } ) ); + +// Silences the warning: dispatchCommand was called with a ref that isn't a native +// component. Use React.forwardRef to get access to the underlying native component. +// This is a known bug of react-native-testing-library package: +// https://github.com/callstack/react-native-testing-library/issues/329#issuecomment-737307473 +jest.mock( 'react-native/Libraries/Components/Switch/Switch', () => { + const jestMockComponent = require( 'react-native/jest/mockComponent' ); + return jestMockComponent( + 'react-native/Libraries/Components/Switch/Switch' + ); +} );