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
# Svelte Help
view-forward
# TestCafe Help
view-forward
# Vue Help
view-forward
Team
Posts
Chat
Members
Info
down-caret

How to check that the correct option is selected?

I need to make sure that the current option is preselected in a certain situation. How can I achieve this? I might add an aria-selected="true", but how to query it?

thumbsup
0
message-simple
3

Assert hidden content after button click

Hello everyone, I just joined the community and I do have a question, let me know if it is not the right place to post it: I've been trying to test a accordion, where the content of a div is hidden when a button is clicked and when I try to assert if the div content is hidden it…

thumbsup
0
message-simple
9

container.update() is not a function

This is the first time I've dealt with act() and I'm trying to act a mockRequest and then update the container and match a snapshot. Is this not possible with Testing Library? await act(async () => { 25 | mockRequest.catch(() => { }).then(() => { …

thumbsup
0
message-simple
2

Testing Complex Applications the Testing Library Way

I am currently considering if the Testing Library really is the right way of testing grown complex applications like I intended to. Test Scenario (also take a look at the image below) …

thumbsup
0
message-simple
2
·21h·Locked# General Help

rerendering components with Provider

The only guides I've found are from two years ago, which claim that this should work: But I haven't gotten this to work. The component seems to rerender, but mapStateToProps isn't called so the new store state isn't used. Is there a way to get rerender and Provider working…

thumbsup
0
message-simple
9

TypeError: Cannot read property 'then' of undefined

I am new in React testing. I am new in React testing. I am using React hooks. I fetched data from the database and pass the props to another component. My app works fine as expected. when I am testing my app and try to render the whole component it gives me test failed. It's…

thumbsup
0
message-simple
2

Help with multiple calls to the same mocked module!

I'm trying to mock axios module using jest's mockResolvedValueOnce(). My component makes 2 calls to axios post (the second depend on the first). For the first call it returns the right value, for the second it gets undefined. Tried everything so far 😥...

thumbsup
0
message-simple
1

Ant Design message is not cleared between tests?

Can someone help me to understand how this happens? Here I've a small component that uses Ant design message.success (https://ant.design/components/message/). I copied the same test twice. The first one passes, but second one fails because it finds more than 1 success message. …

thumbsup
0
message-simple
0

Testing a carousel click drag feature ?

I am trying to test when you click drag then release a click, on a carousel. It should show a new element. The test fails because i am using e.target.offsetLeft in my mouseDown function which returns 0 ? How do i test this ? …

thumbsup
1
message-simple
3

Best way to test clicking sidebar link renders a page?

I was wondering what the best way is to test that clicking on a sidebar link renders the correct page. FYI I am using React Router. This has been shown in many examples before but in those examples all the code is inside the App.tsx component, whereas I have my components split…

thumbsup
0
message-simple
10