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 () {};