Skip to content

include edge case tests for res.type() - #7037

Merged
UlisesGascon merged 2 commits into
expressjs:masterfrom
IshitaSingh0822:master
Feb 23, 2026
Merged

UlisesGascon merged 2 commits into
expressjs:masterfrom
IshitaSingh0822:master

Conversation

@IshitaSingh0822

Copy link
Copy Markdown
Contributor

Description:-
This PR adds edge case tests for res.type() to improve test coverage for the response type-setting functionality.

Motivation:-
While reviewing the test coverage for res.type(), I noticed that several edge cases weren't being tested. These edge cases could lead to unexpected behaviour or bugs in production.

Changes:-
Added 5 new test cases under a new describe('edge cases') block:

  1. Empty string handling - Ensures the function defaults gracefully to application/octet-stream
  2. Extensions with leading dot - Tests .json vs json handling
  3. Multiple file extensions - Tests compound extensions like .tar.gz
  4. Case-insensitive extensions - Ensures FILE.JSON works like file.json
  5. Special characters in filenames - Tests filenames like file@test.json

Testing:-

npm test

All tests passing: 1249 passing (1s)

Impact:-

  • Improves test coverage for res.type()
  • Documents expected behaviour for edge cases
  • Helps prevent future bugs with unusual input
  • No breaking changes to existing functionality

@IshitaSingh0822

Copy link
Copy Markdown
Contributor Author

Hi maintainers, just a gentle reminder for review.
Thanks!

@UlisesGascon UlisesGascon changed the title Ishita🍉 include edge case tests for res.type() Feb 16, 2026

@UlisesGascon UlisesGascon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @IshitaSingh0822!

It can take sometime until we review the prs and merge them to the project. Also I changed the title of the PR to make more descriptive for the reviewers.

I highly recommend you to follow conventional commits or a similar approach to also make the commits more descriptive. In this case is fine, as we will squash it when we land the PR so we can retitle the commit at that step.

Thanks for contributing to the project! ❤️

Comment thread test/res.type.js
- Add extra spacing before edge cases describe block
- Address maintainer feedback

@GroophyLifefor GroophyLifefor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@UlisesGascon
UlisesGascon merged commit b4ab7d6 into expressjs:master Feb 23, 2026
28 checks passed
@UlisesGascon UlisesGascon mentioned this pull request Sep 14, 2026
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.

3 participants