DEV Community

Discussion on: What do you think of React Testing Library?

Collapse
 
acostalima profile image
André Costa Lima

I think JSDOM only provides DOM APIs. It isn't a full-blown rendering engine which is required to determine element's visual and structural properties. You'd have to use some visual testing tool to validate the behavior you described.

Collapse
 
kcvgan profile image
kcvgan

That’s what I concluded after tests but really wanted to test this case programmatically. I guess visual testing it has to be then.

Thread Thread
 
thatzacdavis profile image
Zachary Davis

You could check the styles or classes being applied at least and trust that the CSS is doing it's thing.

Thread Thread
 
kentcdodds profile image
Kent C. Dodds

Yep, that's what I'd recommend. You could also use the style prop and verify the node.style.width is correct.

Thread Thread
 
kcvgan profile image
kcvgan

Thanks, will try!

Thread Thread
 
acostalima profile image
André Costa Lima

Would that really work in this case, i.e., when width is not specified by a CSS class?

Thread Thread
 
kentcdodds profile image
Kent C. Dodds

With JSDOM, you can't measure layout, but you can verify that the style/class name was applied and trust that in the browser's ability to lay it out properly based on that.

Thread Thread
 
acostalima profile image
André Costa Lima

Got it! Thanks! 😄