menu

Testing Library

Simple and complete DOM testing utilities that encourage good testing practices.

Channels
Chat
view-forward
# All channels
view-forward
# General
view-forward
# General Help
view-forward
# Angular Help
view-forward
# Cypress Help
view-forward
# DOM Help
view-forward
# React Help
view-forward
# TestCafe Help
view-forward
# Vue Help
view-forward
Team
Posts
Members
Info

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…

thumbsup
0
message-simple
1

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…

thumbsup
4
message-simple
4

Has anyone successfully used RTL to test change events on a draftJS text box?

The fireEvent.change() just doesn't work. It says there are no setters on the element. …

thumbsup
0
message-simple
29

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…

thumbsup
0
message-simple
2

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…

thumbsup
0
message-simple
10

Is there a way to test for a DOM element that shows up in a custom hook?

I am using the react-hooks part of the library. I am using the renderHook function. Is it possible to get DOM elements from that to see if they have been rendered by the custom hook?

thumbsup
0
message-simple
5

Jest Unit Testing

hi guys here i added a simple login form . and wrote the unit test for that. It works fine but onSubmitting the form it throws an error . But according to logic wise it has to pass but its failing. please help me with…

thumbsup
0
message-simple
1

Test a component that contains multiple components

<div class="summary-bar-cell large-grow sc-fkyLDJ lnGkCP"> <div class="cell-title"> <span class="cell-title-key">Title 1</span> …

thumbsup
0
message-simple
8

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…

thumbsup
0
message-simple
1

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. …

thumbsup
3
message-simple
19