Repository navigation
test(res.redirect): add tests for argument deprecation warnings - #7590
Closed
Gustavo-Luiz2304 wants to merge 1 commit into
Closed
Gustavo-Luiz2304 wants to merge 1 commit into
Gustavo-Luiz2304 wants to merge 1 commit into
Conversation
The deprecation warnings added in expressjs#6405 for missing/non-string url and non-number status had no test coverage. Listen for the depd 'deprecation' event to assert which warnings are emitted. Refs: expressjs#6941 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Duplicate of #7571 |
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.
Summary
#6405 added deprecation warnings to
res.redirect()for a missing/non-stringurland a non-numberstatus, but no tests cover them. This PR adds those tests.Tests only. Nothing in
lib/changes.Details
test/support/env.jssilences express deprecations throughNO_DEPRECATION.depdstill emits thedeprecationevent onprocesswhen a listener is attached, so the new tests listen for that event and check which messages were emitted:res.redirect()→Provide a url argument,Url must be a stringres.redirect(301, undefined)→Provide a url argument,Url must be a stringres.redirect(301, 42)→Url must be a stringres.redirect('301', url)→Status must be a numberI checked that the tests fail when one of the
deprecate()calls is removed.npm testandnpm run lintpass.Related
Refs #6941. This does not close it. Changing
res.redirect()to throw for invalid arguments is the semver-major change in #6404 (6.x). This PR just covers the current 5.x deprecation behavior with tests until then.🤖 Generated with Claude Code