Problem statement
The backend does not have an executable automated test suite. Its committed test script is a placeholder that always exits with failure:
"test": "echo \"Error: no test specified\" && exit 1"
The root package also has no test script. Existing OpenRouter scripts verify static runtime and configuration invariants, but they do not exercise application behavior.
Impact
- CI cannot provide a meaningful regression-test gate.
- Route validation and error handling can regress silently.
- OpenRouter response parsing and error mapping are untested.
- Survey persistence and fallback behavior depend on manual verification.
Scope / proposed approach
Choose a Node-compatible runner, such as Vitest or Node's built-in test runner, then:
- Replace the backend placeholder test script.
- Add deterministic unit tests around pure or mockable service behavior.
- Add focused integration tests for Express routes with external dependencies mocked.
- Add a root-level test command, or clearly document the frontend/backend commands used by CI.
Priority coverage
OpenRouter provider
- Successful response normalization.
- Malformed or empty provider responses.
- HTTP, authentication, rate-limit, and upstream error mapping.
- Timeout and network-failure behavior.
AI routes and services
- Request validation and missing required fields.
- Service success responses.
- Stable status and error payloads on failure.
- Confirmation that tests make no live provider calls.
Survey service
- Persistence success and failure with a mocked Supabase client.
- Latest-survey behavior.
- Malformed AI JSON and fallback behavior.
- Recommendation-save failures.
Test constraints
- Do not call live OpenRouter, Supabase, EmailJS, or other production services.
- Do not require production secrets.
- Keep fixtures deterministic and small.
- Tests must clean up their own temporary state.
- Avoid assertions against unstable log formatting or provider-generated prose.
Acceptance criteria
Verification checklist
npm --prefix backend test
Problem statement
The backend does not have an executable automated test suite. Its committed
testscript is a placeholder that always exits with failure:The root package also has no
testscript. Existing OpenRouter scripts verify static runtime and configuration invariants, but they do not exercise application behavior.Impact
Scope / proposed approach
Choose a Node-compatible runner, such as Vitest or Node's built-in test runner, then:
Priority coverage
OpenRouter provider
AI routes and services
Survey service
Test constraints
Acceptance criteria
npm --prefix backend testruns real tests.Verification checklist
npm --prefix backend test.env.