Unit testing best practices #346
Unanswered
georgewrmarshall
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Unit Test Best Practices
Hello! We're using twrnc in our component library and are looking for best practices on testing whether the correct styles are applied via Tailwind classnames.
Currently, we find ourselves writing helper functions in our tests that essentially duplicate the component's style logic (i.e., generating expected styles using twrnc and comparing them to the rendered output). This feels brittle and tightly coupled to the implementation.
Does anyone have suggestions or examples on how to effectively test that the right styles are applied with twrnc—without duplicating the logic being tested? Are there approaches for asserting rendered styles or classnames in a way that provides confidence but is less fragile?
Any tips, patterns, or resources would be greatly appreciated!
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions