Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to test that a css style property exists for a React component using enzyme + ava?

I'm looking to test that a component has an opacity value of 0 after firing an event, I have not found how to get/check for a specific css property with enzyme (enzyme docs), is it even possible to do it just with enzyme & ava? Or is a third party library needed? At most I get the component props or the class name but I have no access to the style.

OBS: I don't want to use Jest instead of Ava, any other supporting library to work alongside with ava is welcome. For the record, the answers in this question: How to test style for a React component attribute with Enzyme Don't seem to work unless you use Jest.

Versions:

  • ava: 3.8.2
  • enzyme: 3.11.0
  • OS: Catalina (macOs)
  • node: v12.22.X
like image 664
sab Avatar asked Dec 05 '25 18:12

sab


1 Answers

Can't be done if it it not inline style (just with enzyme + ava), it's better to go for e2e tests for UI css checks.

like image 142
sab Avatar answered Dec 08 '25 09:12

sab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!