Skip to content

Conversation

@porada
Copy link

@porada porada commented Oct 27, 2025

What:

This PR implements a new matcher, toHaveTagName, useful for testing polymorphic components.

Why:

expect(myComponent).toHaveTagName('section');

// Much more elegant and expressive than
//
// expect(myComponent.tagName).toStrictEqual('SECTION');

Checklist:

Right now, this is still work in progress. Apart from the checklist below, the feature is currently missing the support for non-lowercase SVG elements and custom elements, plus test coverage.

If there’s consensus around including this matcher, I’ll be happy to finalize it.

  • Documentation
  • Tests
  • Updated type definitions
  • Ready to be merged

@porada
Copy link
Author

porada commented Oct 27, 2025

@gnapse — I’ve been using this custom matcher in my codebase and wanted to formalize it here. Based on past discussions, I believe you expressed interest in adding toHaveTagName at some point. Let me know if I have your green light to finalize the implementation.

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.

1 participant