From 6a4fe1d5e68dd86de21a8bb3539f173a89f9217d Mon Sep 17 00:00:00 2001 From: Adria Navarro Redo Date: Thu, 26 Jan 2023 11:38:21 +0000 Subject: [PATCH] Fix automation test --- packages/backend-core/jest.config.ts | 9 +++++++++ packages/server/jest.config.ts | 16 ++++++++++++++++ .../src/automations/tests/automation.spec.js | 6 +++--- .../src/tests/utilities/TestConfiguration.ts | 4 ++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/packages/backend-core/jest.config.ts b/packages/backend-core/jest.config.ts index 059d3d2a43..133c25734e 100644 --- a/packages/backend-core/jest.config.ts +++ b/packages/backend-core/jest.config.ts @@ -13,4 +13,13 @@ const config: Config.InitialOptions = { }, } +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 c261d109c9..7d5c202f15 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -18,4 +18,20 @@ const config: Config.InitialOptions = { }, } +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 diff --git a/packages/server/src/automations/tests/automation.spec.js b/packages/server/src/automations/tests/automation.spec.js index 4a9f7e2f79..59ee531e9b 100644 --- a/packages/server/src/automations/tests/automation.spec.js +++ b/packages/server/src/automations/tests/automation.spec.js @@ -29,9 +29,9 @@ describe("Run through some parts of the automations system", () => { afterAll(setup.afterAll) it("should be able to init in builder", async () => { - await triggers.externalTrigger(basicAutomation(), { a: 1, appId: "app_123" }) - await wait(100) - expect(thread.execute).toHaveBeenCalled() + await triggers.externalTrigger(basicAutomation(), { a: 1, appId: config.appId }) + await wait(100) + expect(thread.execute).toHaveBeenCalled() }) it("should check coercion", async () => { diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index ff9c82d367..15f090035a 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -399,11 +399,11 @@ class TestConfiguration { // clear any old app this.appId = null // @ts-ignore - await context.updateAppId(null) + context.updateAppId(null) this.app = await this._req({ name: appName }, null, controllers.app.create) this.appId = this.app.appId // @ts-ignore - await context.updateAppId(this.appId) + context.updateAppId(this.appId) // create production app this.prodApp = await this.publish()