1
0
Fork 0
mirror of synced 2024-09-27 14:51:28 +12:00
budibase/packages/server/src/tests/jestSetup.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-01-24 05:45:06 +13:00
import env from "../environment"
import { env as coreEnv } from "@budibase/backend-core"
import { mocks } from "@budibase/backend-core/tests"
2022-05-31 08:46:08 +12: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)
if (!process.env.DEBUG) {
global.console.log = jest.fn() // console.log are ignored in tests
global.console.warn = jest.fn() // console.warn are ignored in tests
}
if (!process.env.CI) {
// set a longer timeout in dev for debugging
// 100 seconds
jest.setTimeout(100000)
}
2023-01-24 05:45:06 +13:00
function overrideConfigValue(key: string, value: string) {
env._set(key, value)
coreEnv._set(key, value)
}
overrideConfigValue("COUCH_DB_PORT", global.__TESTCONTAINERS_DEVENV_PORT_5984__)
overrideConfigValue(
"COUCH_DB_URL",
`http://localhost:${global.__TESTCONTAINERS_DEVENV_PORT_5984__}`
)
overrideConfigValue(
"MINIO_URL",
`http://localhost:${global.__TESTCONTAINERS_DEVENV_PORT_9000__}`
)
2023-01-24 05:53:34 +13:00
overrideConfigValue("COUCH_DB_USERNAME", "test_couchdb_user")
overrideConfigValue("COUCH_DB_PASSWORD", "test_couchdb_password")