Dry, moving env variables to a .env.test file
This commit is contained in:
parent
98aa60879f
commit
d6f0e5b1ec
|
@ -1,15 +1,12 @@
|
|||
module.exports = {
|
||||
module.exports = env => ({
|
||||
devEnv: {
|
||||
image: "budibase/dependencies",
|
||||
tag: "latest",
|
||||
ports: [6379, 5984, 9000],
|
||||
env: {
|
||||
COUCHDB_USER: "test_couchdb_user",
|
||||
COUCHDB_PASSWORD: "test_couchdb_password",
|
||||
},
|
||||
env,
|
||||
wait: {
|
||||
type: "text",
|
||||
text: "Test environment started...",
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
|
@ -87,4 +87,4 @@
|
|||
"install:pro": "bash scripts/pro/install.sh",
|
||||
"dep:clean": "yarn clean && yarn bootstrap"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
JWT_SECRET=testsecret
|
||||
COUCH_DB_PASSWORD=test_couchdb_user
|
||||
COUCH_DB_USER=test_couchdb_password
|
|
@ -1 +1,8 @@
|
|||
module.exports = require("../../jest-testcontainers-config")
|
||||
const { join } = require("path")
|
||||
const { parsed: env } = require("dotenv").config({
|
||||
path: join(__dirname, ".env.test"),
|
||||
})
|
||||
|
||||
const jestTestcontainersConfigGenerator = require("../../jestTestcontainersConfigGenerator")
|
||||
|
||||
module.exports = jestTestcontainersConfigGenerator(env)
|
||||
|
|
|
@ -21,11 +21,20 @@ function isCypress() {
|
|||
}
|
||||
|
||||
let LOADED = false
|
||||
if (!LOADED && isDev() && !isTest()) {
|
||||
require("dotenv").config({
|
||||
path: join(__dirname, "..", ".env"),
|
||||
})
|
||||
LOADED = true
|
||||
if (!LOADED) {
|
||||
if (isDev() && !isTest()) {
|
||||
require("dotenv").config({
|
||||
path: join(__dirname, "..", ".env"),
|
||||
})
|
||||
LOADED = true
|
||||
}
|
||||
// TODO: remove when all tests (cypress, e2e, unit, etc) use docker for testing dependencies
|
||||
else if (isJest()) {
|
||||
require("dotenv").config({
|
||||
path: join(__dirname, "..", ".env.test"),
|
||||
})
|
||||
LOADED = true
|
||||
}
|
||||
}
|
||||
|
||||
function parseIntSafe(number?: string) {
|
||||
|
|
|
@ -26,13 +26,10 @@ function overrideConfigValue(key: string, value: string) {
|
|||
overrideConfigValue("COUCH_DB_PORT", global.__TESTCONTAINERS_DEVENV_PORT_5984__)
|
||||
overrideConfigValue(
|
||||
"COUCH_DB_URL",
|
||||
`http://localhost:${global.__TESTCONTAINERS_DEVENV_PORT_5984__}`
|
||||
`http://${global.__TESTCONTAINERS_DEVENV_IP__}:${global.__TESTCONTAINERS_DEVENV_PORT_5984__}`
|
||||
)
|
||||
|
||||
overrideConfigValue(
|
||||
"MINIO_URL",
|
||||
`http://localhost:${global.__TESTCONTAINERS_DEVENV_PORT_9000__}`
|
||||
`http://${global.__TESTCONTAINERS_DEVENV_IP__}:${global.__TESTCONTAINERS_DEVENV_PORT_9000__}`
|
||||
)
|
||||
|
||||
overrideConfigValue("COUCH_DB_USERNAME", "test_couchdb_user")
|
||||
overrideConfigValue("COUCH_DB_PASSWORD", "test_couchdb_password")
|
||||
|
|
Loading…
Reference in New Issue