From 39554ab32cdeaab4bbb48d98215ccf2413721b85 Mon Sep 17 00:00:00 2001 From: mlanter Date: Tue, 29 Nov 2016 22:05:05 -0800 Subject: [PATCH] Fix missing mock for StatusBarManager Summary: Fix an issue when running Jest unit tests due to a missing mock for StatusBarManger. **More info:** In one of my files I have: ``` export const STATUS_BAR_HEIGHT = (StatusBar.currentHeight || 0); ``` When I run the tests it gives this error, which seems to be because StatusBarManager is undefined (https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js#L20) ``` TypeError: Cannot read property 'HEIGHT' of undefined at Object. (node_modules/react-native/Libraries/Components/StatusBar/StatusBar.js:395:1823) at Object.StatusBar (node_modules/react-native/Libraries/react-native/react-native.js:55:24) ``` **Test plan (required)** Verify that with this change tests that use StatusBar pass. Closes https://github.com/facebook/react-native/pull/11198 Differential Revision: D4246367 Pulled By: cpojer fbshipit-source-id: ee9406d2566688d235a11cab8f24b0583698e93a --- jest/setup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest/setup.js b/jest/setup.js index 1c50bcdc5fb..5b18f88b64b 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -131,6 +131,7 @@ const mockNativeModules = { SourceCode: { scriptURL: null, }, + StatusBarManager: {}, Timing: { createTimer: jest.fn(), deleteTimer: jest.fn(),