-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regex support for .toHaveClass()
#556
Comments
Makes sense. Are you up to contributing this improvement? |
I also faced the same thing now:
and get this:
|
I'm giving it a try in #563. One particularly contentious aspect of it is that I had to tread lightly with an existing feature of |
Hello! I saw the PR is approved by one, but the branch seems to be out of date. Is this being prioritized still? Do you need any support here, by any chance? This would be great for a test I've been just trying to write now. Thanks! |
Thanks for the reminder. Will try to get it merged and released today. |
🎉 This issue has been resolved in version 6.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hello! @gnapse, thanks for tackling this! I really appreciate it 😄 So, I just tried this out (i.e. |
Also, I just tried |
@gnapse, just wanted to follow up on this. Let me know if there's anything I can do to help here, yes? |
Describe the feature you'd like:
With CSS-in-JS and CSS modules, it's pretty common for CSS classes to contain randomly generated unique strings appended to the end. This makes
.toHaveClass()
extremely limited.While there are workarounds involving string matching on the actual class string, these are not ideal because many projects prefer to leave this eslint rule turned on: https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-class.md
If
.toHaveClass()
could accept RegExp in addition to strings, that would allow projects to continue using eslint: prefer-to-have-class while also using CSS Modules / CSS-in-JS.Suggested implementation:
A backwards compatible implementation that simply adds support for RegExp matching for
.toHaveClass()
.Describe alternatives you've considered:
Teachability, Documentation, Adoption, Migration Strategy:
The text was updated successfully, but these errors were encountered: