From 2d86d38e756b203a405c43dd447c4d46fed9f9ea Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Tue, 12 Feb 2019 10:07:02 -0800 Subject: [PATCH] Make AnimatedMock instantly complete spring and timing animations Summary: Some MP E2E tests started failing when I introduced AnimatedMock (D13811035) with this error: > message: Timeout exception: Message: element located by locator {"id":"mp_your_items_tab_button"} is not visible The test relied on the button to animate in, which AnimatedMock disabled. The fix is to complete animations instantly in AnimatedMock. This diff implements that for spring and timing. Reviewed By: cpojer Differential Revision: D14036172 fbshipit-source-id: 18a422ce8ef6de05ff9224c94214524511a76949 --- Libraries/Animated/src/AnimatedMock.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Libraries/Animated/src/AnimatedMock.js b/Libraries/Animated/src/AnimatedMock.js index a30825351c6..6efcdd1815a 100644 --- a/Libraries/Animated/src/AnimatedMock.js +++ b/Libraries/Animated/src/AnimatedMock.js @@ -52,14 +52,28 @@ const spring = function( value: AnimatedValue | AnimatedValueXY, config: SpringAnimationConfig, ): CompositeAnimation { - return emptyAnimation; + const anyValue: any = value; + return { + ...emptyAnimation, + start: (callback?: ?EndCallback): void => { + anyValue.setValue(config.toValue); + callback && callback({finished: true}); + }, + }; }; const timing = function( value: AnimatedValue | AnimatedValueXY, config: TimingAnimationConfig, ): CompositeAnimation { - return emptyAnimation; + const anyValue: any = value; + return { + ...emptyAnimation, + start: (callback?: ?EndCallback): void => { + anyValue.setValue(config.toValue); + callback && callback({finished: true}); + }, + }; }; const decay = function(