Repository navigation
Description
🧭 Project Area
Backend / API
📝 Issue Summary and Problem Description
Issue summary:
The environment configuration module (backend/src/config/env.js) exports three variables: API_PORT, NODE_ENV, and FRONTEND_ORIGIN. The existing test file (backend/tests/unit/env.test.js) only covers API_PORT validation. NODE_ENV and FRONTEND_ORIGIN have zero test coverage.
Problem description:
Without tests for NODE_ENV and FRONTEND_ORIGIN, silent regressions can occur if someone changes the default values or removes the fallback logic. The config module is foundational — every middleware, CORS setup, and route depends on it.
Why this is important:
Environment configuration is a critical path in the application. Missing test coverage for 2 out of 3 environment variables leaves a gap in the CI safety net.
Who is affected:
All developers who depend on NODE_ENV defaulting to "
🔍 Current and Expected Behaviour
Current behaviour:
Only 3 tests exist for env.js, all covering API_PORT. NODE_ENV and FRONTEND_ORIGIN are not tested.
Current result:
Someone could change the NODE_ENV default from "development" to something else and CI would not catch it.
Expected behaviour:
env.js should have full test coverage for all exported environment variables.
Expected result:
4 additional tests covering:
- NODE_ENV defaults to "development" when unset
- NODE_ENV reflects custom values (production, test)
- FRONTEND_ORIGIN defaults to "http://localhost:5173" when unset
- FRONTEND_ORIGIN reflects custom values
🧩 Reproduction and Evidence
Step 1: Run cd backend && npm test
Step 2: Observe that tests 9-11 cover API_PORT only
Step 3: Check env.js — nodeEnv and frontendOrigin have no corresponding tests
Step 4: N/A
Screenshots: N/A
Video (optional): N/A
This is a test coverage gap, not a defect.🎯 Affected Scope
Affected files: backend/tests/unit/env.test.js
Affected APIs: None (test-only change)
Affected components: Environment configuration test suite
Database changes required? No
🖥 Environment
Operating system: Windows 11
Browser and version: N/A (backend tests)
Node.js version: v22.x
Package manager and version: npm 10.x
Docker version: N/A
Deployment environment: Local development
💡 Solution, Alternatives, and Estimate
Priority: P3 Low
Proposed solution: Add 4 new unit tests to backend/tests/unit/env.test.js following the existing save-restore pattern used by the API_PORT tests.
Alternative solutions: Could use a test helper to abstract the env save/restore pattern, but the existing pattern is clear and consistent.
Difficulty: Beginner
Estimated time: 30 minutes
Dependencies or blockers: None
✅ Acceptance Criteria and Additional Notes
- NODE_ENV defaults to "development" when process.env.NODE_ENV is unset
- NODE_ENV reflects the value set in the environment (production, test)
- FRONTEND_ORIGIN defaults to "http://localhost:5173" when unset
- FRONTEND_ORIGIN reflects the value set in the environment
- All existing tests continue to pass
- No changes to production code
Additional notes:
Tests follow the same save-restore pattern as the existing API_PORT tests for consistency.
🤝 Contributor Checklist
- I have searched existing issues and pull requests for duplicates.
- I can reproduce the issue, or I have clearly explained why reproduction is not applicable.
- I will follow the contribution guidelines and target
ecsoc-2026. - I agree to follow the Code of Conduct.
- I have removed secrets, private documents, and personal data.
Activity
Prathvikmehra commentedon Jul 22, 2026
Hi! I'd like to work on this. I'll target the ecsoc-2026 branch and submit a focused PR with the tests described above.
ishhwarrii commentedon Jul 22, 2026
hello @Prathvikmehra , I'd like to work on this issue