[v4] Jest/React Testing Library stopped detecting styling via classes after upgrading from v3 #16456
Unanswered
oskarwilczynski
asked this question in
Help
Replies: 1 comment 1 reply
-
Hey! Could be that happy-dom is not happy with any of the CSS we emit but we mainly focus our output around browsers (https://tailwindcss.com/docs/compatibility#browser-support) so I am not sure what we could do different here. Perhaps, if you want to test computed stylesheets in your app, something like a headless browser (e.g. via playwright) would be more reliable? |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
What version of Tailwind CSS are you using?
v4.0.6
What build tool (or framework if it abstracts the build tool) are you using?
Jest 29.7.0
@testing-library/react 16.0.0
jest-environment-jsdom
happy-dom
What version of Node.js are you using?
22.13.1
What operating system are you using?
macOS
Describe your issue
I have an issue with detecting styling with RTL after upgrading to v4, looks like RTL has issues with picking up styles from Tailwind classes. When using helpers such as
toHaveStyle
ortoBeVisible
, it appears that components are not styled at all:I tried a couple of test environments for Jest and none of them worked -- when using
jest-environment-jsdom
there is an accompanying errorError: Could not parse CSS stylesheet
, withhappy-dom
there's no such error, but the tests that involve styling checks still don't pass.To set up components for tests, I use the following config that injects CSS output file created via
npx @tailwindcss/cli
, it worked completely fine on v3:Has anybody successfully set up Jest/RTL after migrating to v4? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions