diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bfb97ed..37f5086 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,8 +27,5 @@ jobs: - name: Run Build run: npm run build - - name: Set up .env for tests - run: cp .env.template .env - - name: Run Test run: npm test diff --git a/src/common/__tests__/requestLogger.test.ts b/src/common/__tests__/requestLogger.test.ts index 861595f..fdb5aa2 100644 --- a/src/common/__tests__/requestLogger.test.ts +++ b/src/common/__tests__/requestLogger.test.ts @@ -2,7 +2,7 @@ import express from 'express'; import { StatusCodes } from 'http-status-codes'; import request from 'supertest'; -import errorHandler from '@/common/middleware/errorHandler'; // Assuming you have this +import errorHandler from '@/common/middleware/errorHandler'; import requestLogger from '@/common/middleware/requestLogger'; describe('Request Logger Middleware', () => { diff --git a/src/common/utils/envConfig.ts b/src/common/utils/envConfig.ts index fd966fd..73d6a1e 100644 --- a/src/common/utils/envConfig.ts +++ b/src/common/utils/envConfig.ts @@ -1,13 +1,13 @@ import dotenv from 'dotenv'; -import { cleanEnv, host, num, port, str } from 'envalid'; +import { cleanEnv, host, num, port, str, testOnly } from 'envalid'; dotenv.config(); export const env = cleanEnv(process.env, { - NODE_ENV: str({ choices: ['development', 'test', 'production'] }), - HOST: host(), - PORT: port(), - CORS_ORIGIN: str(), - COMMON_RATE_LIMIT_MAX_REQUESTS: num(), - COMMON_RATE_LIMIT_WINDOW_MS: num(), + NODE_ENV: str({ devDefault: testOnly('test'), choices: ['development', 'production', 'test'] }), + HOST: host({ devDefault: testOnly('localhost') }), + PORT: port({ devDefault: testOnly(3000) }), + CORS_ORIGIN: str({ devDefault: testOnly('http://localhost:3000') }), + COMMON_RATE_LIMIT_MAX_REQUESTS: num({ devDefault: testOnly(1000) }), + COMMON_RATE_LIMIT_WINDOW_MS: num({ devDefault: testOnly(1000) }), });