try transfering config to ts(but import is failing)

This commit is contained in:
Annie Huang committed 2024-02-27 00:12:07 +08:00
1 parent 0a730e4eef
commit 004d232a84
2 files changed
+11 -21

No files matched your search

@@ -1,7 +1,7 @@
import { defineConfig } from 'cypress' const { defineConfig } = require('cypress')
import process from 'process' const process = require('process')
import dotenv from 'dotenv' const dotenv = require('dotenv')
import fs from 'fs' // Import fs module const fs = require('fs')
dotenv.config({ path: '../.env.dev' }) dotenv.config({ path: '../.env.dev' })
dotenv.config({ path: '../.env' }) dotenv.config({ path: '../.env' })
@@ -9,19 +9,17 @@ dotenv.config({ path: '../.env' })
const getConfig = (key, defaultValue) => { const getConfig = (key, defaultValue) => {
return process.env[key] || defaultValue return process.env[key] || defaultValue
} }
const getOrFail = (key) => { const getOrFail = (key) => {
const value = getConfig(key) const value = getConfig(key, null)
if (!value) { if (value === null) {
throw new Error(`Missing required environment variable ${key}`) throw new Error(`Missing required environment variable ${key}`)
} }
return value return value
} }
// Check if the .env file exists
const EnableoAuth = fs.existsSync('../.env') const EnableoAuth = fs.existsSync('../.env')
export default defineConfig({ module.exports = defineConfig({
e2e: { e2e: {
baseUrl: getConfig('BASE_URL', 'http://localhost:5173'), baseUrl: getConfig('BASE_URL', 'http://localhost:5173'),
viewportWidth: 1920, viewportWidth: 1920,
@@ -35,13 +33,6 @@ export default defineConfig({
defaultAccount: getOrFail('TESTING_USERNAME'), defaultAccount: getOrFail('TESTING_USERNAME'),
defaultPassword: getOrFail('TESTING_PASSWORD'), defaultPassword: getOrFail('TESTING_PASSWORD'),
isCHVersion: true, isCHVersion: true,
EnableoAuth, // Add the EnableoAuth variable here EnableoAuth,
// google_username: process.env.GOOGLE_USERNAME,
// google_password: process.env.GOOGLE_PASSWORD,
// google_client_id: process.env.GOOGLE_CLIENT_ID,
// github_username: process.env.GITHUB_USERNAME,
// github_password: process.env.GITHUB_PASSWORD,
// github_client_id: process.env.GITHUB_CLIENT_ID,
}, },
}) })
+3 -4
View File
@@ -7,9 +7,8 @@
"include": ["node_modules/cypress", "cypress/**/*.ts"], "include": ["node_modules/cypress", "cypress/**/*.ts"],
"exclude": [ "exclude": [
"node_modules/cypress", "node_modules/cypress",
"cypress.config.mjs", "cypress.config.ts",
"cypress/support/e2e.js", "./cypress/support/e2e.js",
"../packages/utils/**/*.ts", "../packages"
"../packages/file-graph/**/*.ts"
] ]
} }