feat: add testing setup in backend

This commit is contained in:
Lin, Hung-Shin committed 2023-11-17 10:59:47 +08:00
1 parent cb376caff0
commit 1f77328362
15 files changed
+92 -100

No files matched your search

+11 -4
View File
@@ -1,11 +1,19 @@
const { defineConfig } = require('cypress')
const process = require('process')
require('dotenv').config()
require('dotenv').config({ path: '../.env' })
const getConfig = (key, defaultValue) => {
return process.env[key] || defaultValue
}
const getOrFail = (key) => {
const value = getConfig(key)
if (!value) {
throw new Error(`Missing required environment variable ${key}`)
}
return value
}
module.exports = defineConfig({
e2e: {
baseUrl: getConfig('BASE_URL', 'http://localhost:5173'),
@@ -14,9 +22,8 @@ module.exports = defineConfig({
pageLoadTimeout: 120000,
},
env: {
...process.env,
defaultAccount: process.env.default_USERNAME,
defaultPassword: process.env.default_PASSWORD,
defaultAccount: getOrFail('TESTING_USERNAME'),
defaultPassword: getOrFail('TESTING_PASSWORD'),
// google_username: process.env.GOOGLE_USERNAME,
// google_password: process.env.GOOGLE_PASSWORD,
// google_client_id: process.env.GOOGLE_CLIENT_ID,