2022-11-14 23:55:47 +01:00
|
|
|
import { mocks } from "@budibase/backend-core/tests"
|
2022-04-11 15:39:31 +02:00
|
|
|
|
2023-01-27 18:59:14 +01:00
|
|
|
import env from "../environment"
|
|
|
|
import { env as coreEnv } from "@budibase/backend-core"
|
|
|
|
|
2022-11-16 14:06:30 +01:00
|
|
|
// must explicitly enable fetch mock
|
|
|
|
mocks.fetch.enable()
|
|
|
|
|
2022-04-11 15:39:31 +02:00
|
|
|
// mock all dates to 2020-01-01T00:00:00.000Z
|
|
|
|
// use tk.reset() to use real dates in individual tests
|
|
|
|
const tk = require("timekeeper")
|
|
|
|
tk.freeze(mocks.date.MOCK_DATE)
|
2021-05-05 18:49:34 +02:00
|
|
|
|
2022-12-15 12:35:22 +01:00
|
|
|
if (!process.env.DEBUG) {
|
|
|
|
global.console.log = jest.fn() // console.log are ignored in tests
|
|
|
|
}
|
2022-08-25 20:41:47 +02:00
|
|
|
|
|
|
|
if (!process.env.CI) {
|
|
|
|
// set a longer timeout in dev for debugging
|
|
|
|
// 100 seconds
|
|
|
|
jest.setTimeout(100000)
|
|
|
|
}
|
2023-01-27 18:59:14 +01:00
|
|
|
|
|
|
|
function overrideConfigValue(key: string, value: string) {
|
|
|
|
env._set(key, value)
|
|
|
|
coreEnv._set(key, value)
|
|
|
|
}
|
|
|
|
|
|
|
|
const globalSafe = global as any
|
|
|
|
|
2023-01-31 11:18:51 +01:00
|
|
|
console.log(global)
|
|
|
|
|
2023-01-27 18:59:14 +01:00
|
|
|
overrideConfigValue(
|
|
|
|
"COUCH_DB_PORT",
|
2023-01-30 19:15:29 +01:00
|
|
|
globalSafe["__TESTCONTAINERS_COUCHDB-SERVICE-1_PORT_5984__"]
|
2023-01-27 18:59:14 +01:00
|
|
|
)
|
|
|
|
overrideConfigValue(
|
|
|
|
"COUCH_DB_URL",
|
2023-01-30 19:15:29 +01:00
|
|
|
`http://${globalSafe["__TESTCONTAINERS_COUCHDB-SERVICE-1_IP__"]}:${globalSafe["__TESTCONTAINERS_COUCHDB-SERVICE-1_PORT_5984__"]}`
|
2023-01-27 18:59:14 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
overrideConfigValue(
|
|
|
|
"MINIO_URL",
|
2023-01-30 19:15:29 +01:00
|
|
|
`http://${globalSafe["__TESTCONTAINERS_MINIO-SERVICE-1_IP__"]}:${globalSafe["__TESTCONTAINERS_MINIO-SERVICE-1_PORT_9000__"]}`
|
2023-01-27 18:59:14 +01:00
|
|
|
)
|