From 180abafe2977c8338ed0b29851ec464624948659 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Fri, 2 Jul 2021 09:37:24 +0200 Subject: [PATCH] [RNMobile] Mock switch component to address a warning when running tests (#32963) --- test/native/setup.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/native/setup.js b/test/native/setup.js index 6fd0a13c87337..57acb379ca69e 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' + ); +} );