From 0401b09a43b3776e0a533e737b1aa49cafbe7961 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Thu, 15 Jun 2023 19:30:13 +0200 Subject: [PATCH] fix: ensure Application instance initialized early (#10315) --- packages/core/globals/index.ts | 3 +++ packages/core/jest.setup.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/core/globals/index.ts b/packages/core/globals/index.ts index 5c732d9f2..5352d79fb 100644 --- a/packages/core/globals/index.ts +++ b/packages/core/globals/index.ts @@ -370,3 +370,6 @@ function isTestingEnv() { if (!global.NativeScriptHasInitGlobal && !isTestingEnv()) { initGlobal(); } + +// ensure the Application instance is initialized before any other module imports it. +require('@nativescript/core/application'); diff --git a/packages/core/jest.setup.ts b/packages/core/jest.setup.ts index eb4312fe8..40b9597aa 100644 --- a/packages/core/jest.setup.ts +++ b/packages/core/jest.setup.ts @@ -1,4 +1,7 @@ // @ts-nocheck + +jest.mock('@nativescript/core/application', () => null, { virtual: true }); + global.__DEV__ = true; global.WeakRef.prototype.get = global.WeakRef.prototype.deref; global.NativeClass = function () {};