From 7bd4c39929770a74cc2fd2e022199515a28bf0ec Mon Sep 17 00:00:00 2001 From: adrinr Date: Fri, 14 Apr 2023 17:18:15 +0100 Subject: [PATCH] Fix jest when no pro access --- packages/server/jest.config.ts | 7 ++++++- packages/worker/jest.config.ts | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index b00b3b0c31..6a732a9591 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -16,10 +16,15 @@ const baseConfig: Config.InitialProjectOptions = { "@budibase/backend-core": "/../backend-core/src", "@budibase/shared-core": "/../shared-core/src", "@budibase/types": "/../types/src", - "@budibase/pro": "/../pro/packages/pro/src", }, } +// add pro sources if they exist +if (fs.existsSync("../pro/packages")) { + baseConfig.moduleNameMapper!["@budibase/pro"] = + "/../pro/packages/pro/src" +} + const config: Config.InitialOptions = { projects: [ { diff --git a/packages/worker/jest.config.ts b/packages/worker/jest.config.ts index 01a2dd54fd..2b0d8fe23b 100644 --- a/packages/worker/jest.config.ts +++ b/packages/worker/jest.config.ts @@ -16,9 +16,15 @@ const config: Config.InitialOptions = { "@budibase/backend-core/(.*)": "/../backend-core/$1", "@budibase/backend-core": "/../backend-core/src", "@budibase/types": "/../types/src", - "@budibase/pro/(.*)": "/../pro/packages/pro/$1", - "@budibase/pro": "/../pro/packages/pro/src", }, } +// add pro sources if they exist +if (fs.existsSync("../pro/packages")) { + config.moduleNameMapper!["@budibase/pro/(.*)"] = + "/../pro/packages/pro/$1" + config.moduleNameMapper!["@budibase/pro"] = + "/../pro/packages/pro/src" +} + export default config