From 83d4045c01eb743307593b1e0f33f274b8ff8caf Mon Sep 17 00:00:00 2001 From: adrinr Date: Wed, 1 Feb 2023 11:02:29 +0000 Subject: [PATCH] Fix module mappers --- packages/backend-core/jest.config.ts | 18 ++++++------- packages/server/jest.config.ts | 38 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/backend-core/jest.config.ts b/packages/backend-core/jest.config.ts index 649d00af09..2f34b55aa8 100644 --- a/packages/backend-core/jest.config.ts +++ b/packages/backend-core/jest.config.ts @@ -11,6 +11,15 @@ const testContainersSettings = { }, } +if (!process.env.CI) { + // use sources when not in CI + testContainersSettings.moduleNameMapper = { + "@budibase/types": "/../types/src", + } +} else { + console.log("Running tests with compiled dependency sources") +} + const config: Config = { projects: [ { @@ -28,13 +37,4 @@ const config: Config = { coverageReporters: ["lcov", "json", "clover"], } -if (!process.env.CI) { - // use sources when not in CI - config.moduleNameMapper = { - "@budibase/types": "/../types/src", - } -} else { - console.log("Running tests with compiled dependency sources") -} - export default config diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index 331559d825..390167e4c4 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -8,6 +8,25 @@ const testContainersSettings = { preset: "@trendyol/jest-testcontainers", setupFiles: ["./src/tests/jestEnv.ts"], setupFilesAfterEnv: ["./src/tests/jestSetup.ts"], + transform: { + "^.+\\.ts?$": "@swc/jest", + }, +} + +if (!process.env.CI) { + // use sources when not in CI + testContainersSettings.moduleNameMapper = { + "@budibase/backend-core/(.*)": "/../backend-core/$1", + "@budibase/backend-core": "/../backend-core/src", + "@budibase/types": "/../types/src", + } + // add pro sources if they exist + if (fs.existsSync("../../../budibase-pro")) { + testContainersSettings.moduleNameMapper["@budibase/pro"] = + "/../../../budibase-pro/packages/pro/src" + } +} else { + console.log("Running tests with compiled dependency sources") } const config: Config = { @@ -29,25 +48,6 @@ const config: Config = { "!src/db/views/staticViews.*", ], coverageReporters: ["lcov", "json", "clover"], - transform: { - "^.+\\.ts?$": "@swc/jest", - }, -} - -if (!process.env.CI) { - // use sources when not in CI - config.moduleNameMapper = { - "@budibase/backend-core/(.*)": "/../backend-core/$1", - "@budibase/backend-core": "/../backend-core/src", - "@budibase/types": "/../types/src", - } - // add pro sources if they exist - if (fs.existsSync("../../../budibase-pro")) { - config.moduleNameMapper["@budibase/pro"] = - "/../../../budibase-pro/packages/pro/src" - } -} else { - console.log("Running tests with compiled dependency sources") } export default config