test(common): Add unit tests for HttpErrorByCode#17068
Closed
Se3do wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new unit test suite to validate that HttpErrorByCode maps HTTP status codes to the expected exception classes.
Changes:
- Introduces a
HttpErrorByCodespec verifying mapping correctness across a set of status codes. - Adds assertions to ensure the mapping has no extra entries beyond the tested cases.
- Adds a constructibility check for each mapped exception.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c566eb1 to
876c8a4
Compare
Coverage Report for CI Build 374024Coverage remained the same at 90.028%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Member
|
doesn't look like something we'd need a unit test for |
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
HttpErrorByCodehas no unit tests. This utility maps 19 HTTP status codesto their corresponding exception classes (e.g.
400→BadRequestException).It is used by 8 built-in pipes (validation, parse-int, parse-uuid, parse-float,
parse-enum, parse-date, parse-bool, parse-file) to throw the correct HTTP
exception on validation failure. A wrong mapping silently causes all these
pipes to throw the wrong exception across every NestJS application.
Issue Number: N/A
What is the new behavior?
Adds
packages/common/test/utils/http-error-by-code.util.spec.tscovering:(verified by reference equality)
Follows the same
testCases.forEachdata-driven pattern used inhttp.exception.spec.ts.Does this PR introduce a breaking change?
Other information
This change only adds test coverage and does not modify runtime behavior.