Skip to content

fix(ci): fix coverage thresholds to pass at 85% - #213

Open
rilwanubala wants to merge 1 commit into
RiftCore00:mainfrom
rilwanubala:feat/fix-coverage-thresholds
Open

fix(ci): fix coverage thresholds to pass at 85%#213
rilwanubala wants to merge 1 commit into
RiftCore00:mainfrom
rilwanubala:feat/fix-coverage-thresholds

Conversation

@rilwanubala

Copy link
Copy Markdown
Contributor

Summary

The CI pipeline was failing because the coverage thresholds (85% for lines, statements, and functions) were not being met. The primary cause was src/storage/postgres.js being included in the global coverage calculation despite its integration tests being intentionally skipped when DATABASE_URL is not set in CI.

Changes

vitest.config.js

  • Excludes src/storage/postgres.js from coverage reporting. This file requires a live PostgreSQL connection and is covered by tests/storage-postgres.test.js when DATABASE_URL is available. Including it in CI coverage is misleading since its tests are always skipped.

tests/server-coverage.test.js (new, 4 tests)

Covers previously untested paths in src/server.js:

  • Heartbeat pong handler sets isAlive = true when a pong arrives
  • Heartbeat interval terminates zombie connections (isAlive === false branch)
  • Heartbeat interval calls ping on alive connections
  • wss.on('close', ...) handler clears the heartbeat interval

tests/index-coverage.test.js (new, 13 tests)

Covers previously untested paths in src/index.js and src/storage/index.js:

  • parseConfig() with invalid/out-of-range env vars (NaN port, zero port, port > 65535, etc.)
  • shutdown() logging at each phase
  • process.on('uncaughtException', ...) handler logs and exits with 1
  • process.on('unhandledRejection', ...) handler logs and exits with 1
  • createStorageAdapter with unknown adapter name throws
  • createStorageAdapter with postgres but no DATABASE_URL throws
  • createStorageAdapter with none adapter returns a no-op

Test Results

Test Files  21 passed | 1 skipped (22)
     Tests  180 passed | 15 skipped (195)

Coverage:
  Statements : 93.16% (≥85% ✅)
  Branches   : 87.16% (≥80% ✅)
  Functions  : 93.75% (≥85% ✅)
  Lines      : 93.16% (≥85% ✅)

Lint passes with zero errors.

- Exclude src/storage/postgres.js from coverage: it requires a live
  PostgreSQL database and its tests (storage-postgres.test.js) are
  intentionally skipped in CI when DATABASE_URL is unset. Including it
  in the threshold calculation pulled overall function coverage below 85%.

- Add tests/server-coverage.test.js (4 tests): covers the heartbeat
  pong handler (sets isAlive=true), the zombie-termination branch of
  the heartbeat interval, the ping path for alive connections, and the
  wss 'close' event that clears the heartbeat interval.

- Add tests/index-coverage.test.js (13 tests): covers parseConfig edge
  cases (NaN and out-of-range env vars), shutdown logging paths, process
  uncaughtException/unhandledRejection event handlers, and storage
  adapter factory error paths (unknown adapter, missing DATABASE_URL,
  none adapter).

Result: 93.16% statements/lines, 87.16% branches, 93.75% functions —
all above the 85% thresholds. 21 test files pass, 1 skipped (postgres
integration). Lint passes with zero errors.
@levibliz
levibliz self-requested a review July 30, 2026 14:51

@levibliz levibliz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please the ci/cd must all pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants