menu

Testing Library

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

Channels
Team
Posts
Members
Info

Correct type for renderWithRedux function

Could you help me with a problem I'm having with testing-library, redux and typescript? Do you know how I would type this function correctly?

thumbsup
0
message-simple
3

FactoryBot like mocks for different varieties of global state?

So my react testing is limited, most of my testing experience has been backend unit testing. Our App uses MobX, and there are a couple instances of MobX stores(in the form of es6 class instances), UserStore and MasterStore, that contain a lot of access control logic. So when…

thumbsup
0
message-simple
1

Question about query methods when using act

How do you get the methods like getByText, etc.. when rendering using the act function? So for example: Some Context I'm using await act(..) because the component I am rendering is using the useEffect hook and updating some state prop within an async call.

thumbsup
0
message-simple
7

Testing ag-grid with serverside row model type does not render and cell data.

I have a reactJS app built with ag-grid. Its row model type is serverside. I can render the grid with the browser without an issue. But when I use react-testing-library. I can not see and cell data. But if I change that to rowData={myData}, I can see all the rows. What is the…

thumbsup
0
message-simple
0

Invariant violation on using render from testing library

Hi all, I have recently started using the react testing library. Basically, was looking to test a container that renders several other containers. Using the render API resulting in an "Invariant Violation: Element type is invalid: expected a string (for built-in components) or a…

thumbsup
0
message-simple
16

Upgrade from 8.0.7 to 9.1.1 issue

I'm upgrading from 8.0.7 to 9.1.1 and I'm suddenly getting the following issue on simple component renders that I have multiple tests for. Found multiple elements with the title: 'Title'. The only change I have made is to remove the 'import…

thumbsup
0
message-simple
1

Testing input change with addEventListener doesn't work

Hello hackers , I'm having some issues with a test at work , the strange part is it passes when it runs with the whole test suite but when I run it with .only it fails . I managed to extract the test into a simple reproducible example…

thumbsup
0
message-simple
0

Tetsing Redux actions

``` export const fetchSpecificSentMessageAction = ({ messageId, …

thumbsup
0
message-simple
6

`act` warning

Hi, Can anyone help me with this simple example? React 16.9.0 …

thumbsup
0
message-simple
15

Testing connected redux components with mapDispatchToProps

Hi, I've got a component that has both redux state and action creators connected. I'd like to test that an action is dispatched when a button is clicked, and check that it's called with the params I expect - see example…

thumbsup
0
message-simple
11