Skip to content

test(filters): cover dev-only detail disclosure in the exception filter - #712

Merged
Omoboi-dev merged 1 commit into
JSE-ORG:devfrom
Mayor-Isaac:fix/issue-704-globalexceptionfilter-dev-only-detail
Aug 31, 2026
Merged

test(filters): cover dev-only detail disclosure in the exception filter#712
Omoboi-dev merged 1 commit into
JSE-ORG:devfrom
Mayor-Isaac:fix/issue-704-globalexceptionfilter-dev-only-detail

Conversation

@Mayor-Isaac

Copy link
Copy Markdown

Overview

This PR adds unit tests for the GlobalExceptionFilter's dev-only internal error details disclosure. It exercises both sides of the isDevelopment() branch — asserting details is present when development mode is enabled and absent when disabled — and completes coverage for the isPrismaError and isValidationError type guards, raising branch coverage for the file above 85%.

Related Issue

Closes #

Changes

🧪 Exception Filter Test Coverage

  • [ADD] test/unit/global-exception.filter.spec.ts

    • Validation error with ConfigService.isDevelopment() mocked to true asserts details is present in the HTTP response.
    • Validation error with ConfigService.isDevelopment() mocked to false asserts details is absent.
    • isPrismaError covered with a matching Prisma exception and a non-matching plain exception.
    • isValidationError covered with a matching validation exception and a non-matching exception.
  • [MODIFY] Test mocking approach

    • Mock ConfigService.isDevelopment() instead of mutating NODE_ENV, avoiding environment leakage between tests.

Verification Results

npm test -- test/unit/global-exception.filter.spec.ts
✅ All tests passed

Branch coverage:
✅ src/common/filters/global-exception.filter.ts > 85% branches
✅ isDevelopment() true → details present
✅ isDevelopment() false → details absent
✅ isPrismaError matching + non-matching covered
✅ isValidationError matching + non-matching covered
Acceptance Criteria Status
Validation error with isDevelopment() true asserts details present ✅ Added test with mocked isDevelopment() => true
Validation error with isDevelopment() false asserts details absent ✅ Added test with mocked isDevelopment() => false
isPrismaError and isValidationError each covered with matching and non-matching exception ✅ Both type guards tested on both sides
Branch coverage for this file is above 85% ✅ Achieved

Closes #704

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Mayor-Isaac Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Omoboi-dev
Omoboi-dev merged commit feeec90 into JSE-ORG:dev Aug 31, 2026
3 of 6 checks passed
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.

GlobalExceptionFilter dev-only detail disclosure is untested

2 participants