From 004d232a84ce82bdc6f517da89ec51774743f0e3 Mon Sep 17 00:00:00 2001 From: Annie Huang Date: Tue, 27 Feb 2024 00:12:07 +0800 Subject: [PATCH] try transfering config to ts(but import is failing) --- .../{cypress.config.mjs => cypress.config.ts} | 25 ++++++------------- tests/tsconfig.json | 7 +++--- 2 files changed, 11 insertions(+), 21 deletions(-) rename tests/{cypress.config.mjs => cypress.config.ts} (53%) diff --git a/tests/cypress.config.mjs b/tests/cypress.config.ts similarity index 53% rename from tests/cypress.config.mjs rename to tests/cypress.config.ts index 5e5d8c2..83188db 100644 --- a/tests/cypress.config.mjs +++ b/tests/cypress.config.ts @@ -1,7 +1,7 @@ -import { defineConfig } from 'cypress' -import process from 'process' -import dotenv from 'dotenv' -import fs from 'fs' // Import fs module +const { defineConfig } = require('cypress') +const process = require('process') +const dotenv = require('dotenv') +const fs = require('fs') dotenv.config({ path: '../.env.dev' }) dotenv.config({ path: '../.env' }) @@ -9,19 +9,17 @@ dotenv.config({ path: '../.env' }) const getConfig = (key, defaultValue) => { return process.env[key] || defaultValue } - const getOrFail = (key) => { - const value = getConfig(key) - if (!value) { + const value = getConfig(key, null) + if (value === null) { throw new Error(`Missing required environment variable ${key}`) } return value } -// Check if the .env file exists const EnableoAuth = fs.existsSync('../.env') -export default defineConfig({ +module.exports = defineConfig({ e2e: { baseUrl: getConfig('BASE_URL', 'http://localhost:5173'), viewportWidth: 1920, @@ -35,13 +33,6 @@ export default defineConfig({ defaultAccount: getOrFail('TESTING_USERNAME'), defaultPassword: getOrFail('TESTING_PASSWORD'), isCHVersion: true, - EnableoAuth, // Add the EnableoAuth variable here - // 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, + EnableoAuth, }, }) diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 34b9337..cf23123 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -7,9 +7,8 @@ "include": ["node_modules/cypress", "cypress/**/*.ts"], "exclude": [ "node_modules/cypress", - "cypress.config.mjs", - "cypress/support/e2e.js", - "../packages/utils/**/*.ts", - "../packages/file-graph/**/*.ts" + "cypress.config.ts", + "./cypress/support/e2e.js", + "../packages" ] }