You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is, that I would really like to be able to use the .toHaveStyleRule as a way to extend this test, so that my matcher could look something like this:
NOTE: Obviously my use case is way more complex than this one that I illustrated, I have multiple styles to check for customization, and I'd implement my own logic for determining if the customization have been applied or not. But I'd still count on the styling base logic already implemented on toHaveStyleRule to help me make those assertions.
I'm wondering if this is a good practice in tests (using external matches) and if this is something that could be possible in a future version. I'm more than happy to open a PR for this, exporting the toHaveStyleRule method.
The text was updated successfully, but these errors were encountered:
Hi 👋
I maintain a small library that allows specific customizations to styled-components.
I found that testing those styles is becoming too repetitive since on every test file I have to repeat the same testing logic, which is basically:
My current idea is to create a jest matcher, something along the lines of
.toHaveCustomization
in order to test all the customizations.Just to illustrate, my customizations look something along the lines of:
The problem is, that I would really like to be able to use the
.toHaveStyleRule
as a way to extend this test, so that my matcher could look something like this:NOTE: Obviously my use case is way more complex than this one that I illustrated, I have multiple styles to check for customization, and I'd implement my own logic for determining if the customization have been applied or not. But I'd still count on the styling base logic already implemented on
toHaveStyleRule
to help me make those assertions.I'm wondering if this is a good practice in tests (using external matches) and if this is something that could be possible in a future version. I'm more than happy to open a PR for this, exporting the
toHaveStyleRule
method.The text was updated successfully, but these errors were encountered: