chore(backend): add contract tests for errorHandler mapping to http status codes#278
Merged
greatest0fallt1me merged 3 commits intoApr 23, 2026
Conversation
|
@Joeloo1 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implement comprehensive contract tests for the errorHandler middleware to ensure correct mapping of error classes to HTTP status codes. This PR also includes security enhancements and robustness improvements for error identification.
Closes #258
Changes
Test Output
PASS src/middleware/errorHandler.test.ts
Error Handler
✓ should handle AppError with correct response shape
✓ should handle generic Error with default values
...
✓ map ForbiddenError to 403
✓ map NotFoundError to 404
✓ map PaymentRequiredError to 402
✓ map TooManyRequestsError to 429
Error Handler - Production Environment
✓ should mask generic error message in production
✓ should NOT mask AppError messages in production
Test Suites: 1 passed, 1 total
Tests: 12 passed, 12 total
Security & Data Integrity Notes