Unit tests with twin.macro #711
Unanswered
DavidReinertToptal
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hey there I haven't gone through this proceedure before but I'd probably look at extending the test runner by a custom test function. eg: expect(element).toHaveTwStyle('text-red-500'); Then in that function, you could grab the style from the config (either directly from the preset or with twins theme import?) That way you will have a better chance of using a find+replace on the current tests. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey all. I'm currently in the process of migrating apps from TailwindCSS to twin.macro + @emotion/react and I was looking for tips or advice on the best or least painful way to migrate unit tests. I have quite a large number of unit tests for various React components that have assertions like:
I am aware of the @emotion/jest package that would allow me to at least assert against the styles applied by emotion, but that alone would still involve manually updating over 100 tests from the above syntax to:
which would be quite cumbersome and time consuming, especially since some of these tests assert more than one Tailwind class.
Any tips or tools anyone knows of to make this sort of update less painful would be greatly appreciated 🙏
Beta Was this translation helpful? Give feedback.
All reactions