From bef051d9d83b6b8faf6b7a021e48438e000a9863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20M=C3=A4mecke?= Date: Fri, 14 Feb 2020 09:38:21 +0100 Subject: [PATCH] Add global window to jest setup `window` exists in the React Native runtime, but not inside the test environment. Many libraries use `typeof window === 'undefined'` to check if code is running in SSR. Because of the difference in the real environment and test environment, tests can behave different than the real app, which is an unwanted behavior. --- jest/setup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest/setup.js b/jest/setup.js index 9a439f81537530..912b5f78dcee58 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -23,6 +23,7 @@ global.performance = { global.Promise = jest.requireActual('promise'); global.regeneratorRuntime = jest.requireActual('regenerator-runtime/runtime'); +global.window = global; global.requestAnimationFrame = function(callback) { return setTimeout(callback, 0);