change e2e to use node module

This commit is contained in:
wancat committed 2024-02-08 17:40:01 +08:00
1 parent f797f4d897
commit c06d6d6deb
8 files changed
+29 -13

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
TESTING=true
TESTING_USERNAME=alex
TESTING_PASSWORD=Alex1234
SECRET_KEY=b1d2e917-17b9-4fce-9055-082dee6ec5d6
+1 -1
View File
@@ -8,7 +8,7 @@ COPY packages/file-graph/package.json ./packages/file-graph/package.json
COPY packages/utils/package.json ./packages/utils/package.json COPY packages/utils/package.json ./packages/utils/package.json
COPY packages/constants/package.json ./packages/constants/package.json COPY packages/constants/package.json ./packages/constants/package.json
COPY app/package.json ./app/package.json COPY app/package.json ./app/package.json
RUN yarn install RUN yarn install
# Dev stage # Dev stage
FROM base as dev FROM base as dev
+2 -2
View File
@@ -6,8 +6,8 @@ services:
dockerfile: tests/Dockerfile dockerfile: tests/Dockerfile
networks: networks:
- internal - internal
volumes: # volumes:
- ./tests:/e2e/tests # - ./tests:/e2e/tests
environment: environment:
- BASE_URL=http://app-test - BASE_URL=http://app-test
- TESTING_USERNAME=alex - TESTING_USERNAME=alex
+1 -1
View File
@@ -9,7 +9,7 @@
"setup": "node dist/cli/setup.js", "setup": "node dist/cli/setup.js",
"clean": "node dist/cli/clean.js", "clean": "node dist/cli/clean.js",
"build": "tsc", "build": "tsc",
"watch": "concurrently \"tsc -w\" \"nodemon\"", "watch": "concurrently \"nodemon\" \"tsc -w\"",
"build:quests": "node dist/cli/build.js" "build:quests": "node dist/cli/build.js"
}, },
"dependencies": { "dependencies": {
+5
View File
@@ -4,6 +4,9 @@ import { get } from './utils/env.js'
// Import dotenv and load ../.env // Import dotenv and load ../.env
dotenv.config({ path: '../.env' }) dotenv.config({ path: '../.env' })
if (process.env.NODE_ENV !== 'production') {
dotenv.config({ path: '../.env.dev' })
}
function getTrustProxies(key) { function getTrustProxies(key) {
if (!process.env[key]) { if (!process.env[key]) {
@@ -68,4 +71,6 @@ export function getQuestImage(id) {
return `${config.docker.imagePrefix}${id}` return `${config.docker.imagePrefix}${id}`
} }
console.log(config)
export default config export default config
+6 -3
View File
@@ -1,10 +1,13 @@
FROM cypress/included:13.5.1 FROM cypress/browsers:node-20.11.0-chrome-121.0.6167.85-1-ff-120.0-edge-121.0.2277.83-1
WORKDIR /e2e WORKDIR /e2e
RUN yarn set version stable
COPY package.json yarn.lock ./ COPY package.json yarn.lock ./
COPY tests/package.json ./tests/package.json COPY tests/package.json ./tests/package.json
RUN yarn install --frozen-lockfile RUN yarn config set -H enableImmutableInstalls false
RUN yarn install
COPY quests ./quests COPY quests ./quests
COPY tests ./tests COPY tests ./tests
WORKDIR /e2e/tests WORKDIR /e2e/tests
CMD [ "yarn", "test:e2e" ]
@@ -1,6 +1,9 @@
const { defineConfig } = require('cypress') import { defineConfig } from 'cypress'
const process = require('process') import process from 'process'
require('dotenv').config({ path: '../.env' }) import dotenv from 'dotenv'
dotenv.config({ path: '../.env.dev' })
dotenv.config({ path: '../.env' })
const getConfig = (key, defaultValue) => { const getConfig = (key, defaultValue) => {
return process.env[key] || defaultValue return process.env[key] || defaultValue
@@ -14,7 +17,7 @@ const getOrFail = (key) => {
return value return value
} }
module.exports = defineConfig({ export default defineConfig({
e2e: { e2e: {
baseUrl: getConfig('BASE_URL', 'http://localhost:5173'), baseUrl: getConfig('BASE_URL', 'http://localhost:5173'),
viewportWidth: 1920, viewportWidth: 1920,
+3 -2
View File
@@ -3,10 +3,11 @@
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"main": "index.js", "main": "index.js",
"type": "module",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "TESTING_USERNAME=alex TESTING_PASSWORD=Alex1234 cypress run", "test": "yarn cypress run",
"test:open": "TESTING_USERNAME=alex TESTING_PASSWORD=Alex1234 cypress open" "test:open": "yarn cypress open"
}, },
"dependencies": { "dependencies": {
"@testing-library/cypress": "^10.0.1", "@testing-library/cypress": "^10.0.1",