Problem
The test runner currently reports "Tests: 68 passed, 68 total" while four test suites silently fail at suite-load because testEnv/setup.ts sets MONGO_URI but not MONGO_DB_NAME. Exit code is 1, but the green "68 passed" line is what catches the eye.
The four failing suites are the storage layer specs — the ones that exercise the Mongo connection code, which is exactly where most of the production complexity lives.
Compounding this, the deploy workflow runs no tests at all. Code goes from git push → Docker build → Cloud Run deploy with no unit-test gate, no Cypress gate, no tsc --noEmit gate. The only thing that can fail the deploy is a TypeScript compile error (because that fails the Docker build).
Current Impact
- 4 storage test suites (82 tests total) silently fail during test setup
- Test runner reports misleading "68 passed" when actually 14 suites failed to load
- New tests added in Brief 1 won't catch regressions if nobody runs them
- Existing tests don't catch regressions if nobody notices when they break
- Bugs that the test suite would catch ship to production
Failing Test Suites
group.mongodb.service.spec.ts
meeting.mongodb.service.byGroup.spec.ts
meeting.mongodb.service.bySlug.spec.ts
meeting.mongodb.service.query.spec.ts
Root Cause
The top-level await in mongodb-storage-service.ts reads the env var at module load time. When storage specs are imported, MONGO_DB_NAME is undefined, causing suite-load failure before any tests can run.
Proposed Solution
Three changes:
1. Fix testEnv/setup.ts
Add one line before storage module is first imported:
process.env.MONGO_DB_NAME = dbConfig.Database
This ensures the environment variable is set before any test suite imports the storage modules.
2. Add test step to deploy workflow
In .github/workflows/deploy-cloudrun.yml (or in a new workflow that runs on PR), add before the Docker build step:
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Type check
run: npx tsc --noEmit
If tests fail, the deploy doesn't happen. This is the minimum CI gate.
3. Add coverage floor (optional but cheap)
Set Jest's coverageThreshold to current levels to prevent accidental regression:
{
"coverageThreshold": {
"global": {
"statements": 95,
"branches": 78
}
}
}
4. Create .env.example file
Document required environment variables for new contributors:
MONGO_URI=mongodb://localhost:27017
MONGO_DB_NAME=central-query-test
NODE_ENV=development
Acceptance Criteria
Notes
The top-level await in mongodb-storage-service.ts reads the env var at module load time, which is why all four storage specs fail at suite-load before any tests can run.
Without this fix, the new tests added in Brief 1 won't catch regressions, and bugs that the test suite would catch will ship to production.
~45 minutes including workflow testing.
Problem
The test runner currently reports "Tests: 68 passed, 68 total" while four test suites silently fail at suite-load because
testEnv/setup.tssetsMONGO_URIbut notMONGO_DB_NAME. Exit code is 1, but the green "68 passed" line is what catches the eye.The four failing suites are the storage layer specs — the ones that exercise the Mongo connection code, which is exactly where most of the production complexity lives.
Compounding this, the deploy workflow runs no tests at all. Code goes from
git push→ Docker build → Cloud Run deploy with no unit-test gate, no Cypress gate, notsc --noEmitgate. The only thing that can fail the deploy is a TypeScript compile error (because that fails the Docker build).Current Impact
Failing Test Suites
group.mongodb.service.spec.tsmeeting.mongodb.service.byGroup.spec.tsmeeting.mongodb.service.bySlug.spec.tsmeeting.mongodb.service.query.spec.tsRoot Cause
The top-level
awaitinmongodb-storage-service.tsreads the env var at module load time. When storage specs are imported,MONGO_DB_NAMEis undefined, causing suite-load failure before any tests can run.Proposed Solution
Three changes:
1. Fix
testEnv/setup.tsAdd one line before storage module is first imported:
This ensures the environment variable is set before any test suite imports the storage modules.
2. Add test step to deploy workflow
In
.github/workflows/deploy-cloudrun.yml(or in a new workflow that runs on PR), add before the Docker build step:If tests fail, the deploy doesn't happen. This is the minimum CI gate.
3. Add coverage floor (optional but cheap)
Set Jest's
coverageThresholdto current levels to prevent accidental regression:{ "coverageThreshold": { "global": { "statements": 95, "branches": 78 } } }4. Create
.env.examplefileDocument required environment variables for new contributors:
Acceptance Criteria
npm testreports 16 passed suites, 82 passed tests, exit 0.env.exampleexists and documents required variablesNotes
The top-level
awaitinmongodb-storage-service.tsreads the env var at module load time, which is why all four storage specs fail at suite-load before any tests can run.Without this fix, the new tests added in Brief 1 won't catch regressions, and bugs that the test suite would catch will ship to production.
~45 minutes including workflow testing.