Tests throwing async callback 5000ms timeout errors after upgrading to v9.4.0
In most of my unit tests I'm mocking the response of the axios async callback with jest. And the format is as follows: The above used to work with older versions of testing-library/react and now I'm facing failing tests due to Timeout - Async callback was not invoked within the…
Testing components that should throw
I'm using componentDidCatch on top parent component to handle generic errors. In my component therefore I'm throwing if some unknown API error happens and I can't handle it. Of course I would like to test this component if it throws, when API error happens. And it does, test…
How to query?
General title but not sure how do make it better without making it a mile long. To explain where this comes from: Me and several other developers are doing a web app to track dice results in a game. For now it's going to be in our native language of Swedish but we want to be…
Best way to test hidden by CSS class?
I have a component that contains some additional information that sometimes gets hidden. I do this by adding a css class to the additional information elements in the component. So given the philosophy of the library I wasn't sure of the best way to test this. I can't get the…
Proper use of getAllByText to find the target matching element
I have a document with two buttons. One is 'save' and the other is 'save as'. In the test to make sure the 'save' button appears on the page, I use 'getAllByText' to find elements that match /save/i. What is the best way to make sure I am looking at the 'save' button instead of…
Material-UI Textfield Select (non-native)
Has anyone manage to successfully use RTL to test a Material UI dropdown, and if so, how? Problem: Cannot successfully use any of the RTL getBy* queries to identify and then 'click' the correct child of a Textfield component, so as to choose an option from the dropdown. …