diff --git a/packages/backend-core/__mocks__/aws-sdk.ts b/packages/backend-core/__mocks__/aws-sdk.ts new file mode 100644 index 0000000000..7fac80faa9 --- /dev/null +++ b/packages/backend-core/__mocks__/aws-sdk.ts @@ -0,0 +1,15 @@ +const mockS3 = { + headBucket: jest.fn().mockReturnThis(), + deleteObject: jest.fn().mockReturnThis(), + deleteObjects: jest.fn().mockReturnThis(), + createBucket: jest.fn().mockReturnThis(), + listObjects: jest.fn().mockReturnThis(), + promise: jest.fn().mockReturnThis(), + catch: jest.fn(), +} + +const AWS = { + S3: jest.fn(() => mockS3), +} + +export default AWS diff --git a/packages/backend-core/__mocks__/node-fetch.ts b/packages/backend-core/__mocks__/node-fetch.ts new file mode 100644 index 0000000000..4c7127ee48 --- /dev/null +++ b/packages/backend-core/__mocks__/node-fetch.ts @@ -0,0 +1 @@ +jest.mock("node-fetch", () => jest.fn()) diff --git a/packages/backend-core/src/middleware/passport/tests/oidc.spec.js b/packages/backend-core/src/middleware/passport/tests/oidc.spec.js index c00ab2ea7d..4c8aa94ddf 100644 --- a/packages/backend-core/src/middleware/passport/tests/oidc.spec.js +++ b/packages/backend-core/src/middleware/passport/tests/oidc.spec.js @@ -1,7 +1,6 @@ // Mock data - +const mockFetch = require("node-fetch") const { data } = require("./utilities/mock-data") - const issuer = "mockIssuer" const sub = "mockSub" const profile = { @@ -39,8 +38,6 @@ describe("oidc", () => { const mockStrategy = require("@techpass/passport-openidconnect").Strategy // mock the request to retrieve the oidc configuration - jest.mock("node-fetch") - const mockFetch = require("node-fetch") mockFetch.mockReturnValue({ ok: true, json: () => oidcConfigUrlResponse diff --git a/packages/backend-core/tests/jestSetup.ts b/packages/backend-core/tests/jestSetup.ts index 1478da3afb..30b645d0e5 100644 --- a/packages/backend-core/tests/jestSetup.ts +++ b/packages/backend-core/tests/jestSetup.ts @@ -10,6 +10,9 @@ env._set("SELF_HOSTED", "1") env._set("NODE_ENV", "jest") env._set("JWT_SECRET", "test-jwtsecret") env._set("LOG_LEVEL", "silent") +env._set("MINIO_URL", "http://localhost") +env._set("MINIO_ACCESS_KEY", "test") +env._set("MINIO_SECRET_KEY", "test") global.console.log = jest.fn() // console.log are ignored in tests diff --git a/packages/server/src/tests/jestSetup.ts b/packages/server/src/tests/jestSetup.ts index 5c354d3a44..c178cb4449 100644 --- a/packages/server/src/tests/jestSetup.ts +++ b/packages/server/src/tests/jestSetup.ts @@ -8,6 +8,9 @@ env._set("CLIENT_ID", "test-client-id") env._set("BUDIBASE_DIR", tmpdir("budibase-unittests")) env._set("LOG_LEVEL", "silent") env._set("PORT", 0) +env._set("MINIO_URL", "http://localhost") +env._set("MINIO_ACCESS_KEY", "test") +env._set("MINIO_SECRET_KEY", "test") import { mocks } from "@budibase/backend-core/tests" diff --git a/packages/worker/__mocks__/aws-sdk.ts b/packages/worker/__mocks__/aws-sdk.ts new file mode 100644 index 0000000000..7fac80faa9 --- /dev/null +++ b/packages/worker/__mocks__/aws-sdk.ts @@ -0,0 +1,15 @@ +const mockS3 = { + headBucket: jest.fn().mockReturnThis(), + deleteObject: jest.fn().mockReturnThis(), + deleteObjects: jest.fn().mockReturnThis(), + createBucket: jest.fn().mockReturnThis(), + listObjects: jest.fn().mockReturnThis(), + promise: jest.fn().mockReturnThis(), + catch: jest.fn(), +} + +const AWS = { + S3: jest.fn(() => mockS3), +} + +export default AWS diff --git a/packages/worker/__mocks__/node-fetch.ts b/packages/worker/__mocks__/node-fetch.ts new file mode 100644 index 0000000000..4c7127ee48 --- /dev/null +++ b/packages/worker/__mocks__/node-fetch.ts @@ -0,0 +1 @@ +jest.mock("node-fetch", () => jest.fn()) diff --git a/packages/worker/src/tests/jestSetup.ts b/packages/worker/src/tests/jestSetup.ts index 8405f5bf82..2af4deff8e 100644 --- a/packages/worker/src/tests/jestSetup.ts +++ b/packages/worker/src/tests/jestSetup.ts @@ -5,6 +5,9 @@ env._set("NODE_ENV", "jest") env._set("JWT_SECRET", "test-jwtsecret") env._set("LOG_LEVEL", "silent") env._set("MULTI_TENANCY", true) +env._set("MINIO_URL", "http://localhost") +env._set("MINIO_ACCESS_KEY", "test") +env._set("MINIO_SECRET_KEY", "test") import { mocks } from "@budibase/backend-core/tests"