From a4acd8899fa3344094a86ccc05c7dfee99971e8f Mon Sep 17 00:00:00 2001 From: Ryan Dy Date: Wed, 12 Jun 2019 06:20:36 -0700 Subject: [PATCH] mock Animated components with versions that skipSetNativeProps (#25108) Summary: Using Animated components like View and Image do not get created with __skipSetNativeProps_FOR_TESTS_ONLY = true since they get created before the jest mock can be applied to createAnimatedComponent. For these components mock getters to create versions that properly skip set native props. Jest tests that render these components get warnings the setNativeProps gets called even though using a testRenderer this should not happen. ## Changelog [Javascript] [Fixed] - Define Animated Components for react-native/jest/setup that properly skip setNativeProps Pull Request resolved: https://github.com/facebook/react-native/pull/25108 Differential Revision: D15779434 Pulled By: cpojer fbshipit-source-id: f39e21ed8e71c2c155297c791d3bf573909896d6 --- jest/setup.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jest/setup.js b/jest/setup.js index cdd146462fe..231c2c65314 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -127,6 +127,12 @@ jest '../Libraries/Components/ActivityIndicator/ActivityIndicator', ), ) + .mock('../Libraries/Animated/src/Animated', () => { + const Animated = jest.requireActual('../Libraries/Animated/src/Animated'); + Animated.Text.__skipSetNativeProps_FOR_TESTS_ONLY = true; + Animated.View.__skipSetNativeProps_FOR_TESTS_ONLY = true; + return Animated; + }) .mock('../Libraries/Animated/src/AnimatedImplementation', () => { const AnimatedImplementation = jest.requireActual( '../Libraries/Animated/src/AnimatedImplementation',