DEV Community

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

Collapse
 
ronnewcomb profile image
Ron Newcomb

I do not like it.

I get random "should call act" errors depending on which device I run the test. If fireEvent.click needs to be wrapped in act() to be dependable, it should use it itself. Instead I have to wrap it myself every time. My test code is ugly and long-winded.

It promises interaction like the user does, but I can't get "the sort icon beside the column header". It has a function "within" but its use seems to be more for typecasting from HTMLElement to whatever internal type it uses rather than looking in the HTMLElement's children.

I have to step outside the framework to use .closest(..) to find elements "like a user would".

I have to add role, name, and other nonfunctional attributes to several places to my code because I cannot find by icon... because I'm not allowed to find by the class which puts the icon there. (FontAwesome, etc.)

I end up with tests that navigate by a mishmash of screenreader landmarks and visual landmarks, so I have no guarantee that either method of navigation works for either type of user.

I can't string the element, findBy, click calls in a fluent interface. The closest I get is with findBy(...) because I can string on .then(fireEvent.click). But this randomly throws the "act(...)" error depending on device, even when teh whole line has await. So instead I'm forced to write tests that read like a dick-and-jane English primer instead of a more natural style.

I can't get "the only select element on the popup" like a user would because I can't find by HTML tagname.

GetByText gets text from closed dropdowns and non-visible popups, making it largely useless. (Bootstrap3)

Getting an easily visible element by a combination of factors isn't possible. All my column headers have "click to filter" title, all my column headers' texts appear again in a dropdown or two, i actually want the sort icon beside the text in the header but there's one per column.... I can only get/find/query by a single criteria. I'm reduced to array indexes.


I like the idea behind this framework, but it's implementation leaves a lot to be desired.