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

event.propertyName returns undefined when I'm using fireEvent.transitionEnd

This is my function, I'm trying to test that the callback function work in my tests: ...I'm firing this in my test: fireEvent.transitionEnd(getByTestId('sidepanel')); …

thumbsup
0
message-simple
0

Is there a way to use the dom-testing-library with puppeteer?

thumbsup
1
message-simple
9

Testing Library vs e2e

Where do people draw the line between testing library and e2e testing? In react native, e2e takes forever, can be flaky, and is yet another framework to learn/setup/deploy. I've resorted to using testing library as my e2e, and then manually do spot inspections. Seems to work…

thumbsup
2
message-simple
24

Is there a preferred method for testing if an element on the page exists?

All of these examples achieve the same thing 1. getByText('foo') 2. expect(() => getByText('foo')).not.toThrow() …

thumbsup
0
message-simple
5

How do I let RTL change component state on triggering onChange?

I'm using fireEvent.change(getByTestId('some-id')), and after that, I'm triggering a button's click using fireEvent and it runs a method that does an async operation and after getting a response from server it updates the state of the component. I'm confused when RTL fireEvent…

thumbsup
0
message-simple
17

How are you testing panding states of your application?

I want to make sure that the users gets feedback if something is loading after an action got triggered. For example a loading spinner is displayed after a form is submitted. Therefore I need to assert just before the request gets resolved. How are you testing this? My current…

thumbsup
0
message-simple
9

How to test element is focused

I would like to know if an input I have is focused when another element is clicked... How would I do this? Eg: https://codesandbox.io/s/616nl7q2pk

thumbsup
0
message-simple
5

Test that something is not on the page

I have a test similar to this one This works fine. I would like to do the opposite. I want to test non-admin can not open the modal. In this scenario the button is still on the page, it just doesn't open the modal on click. I'm aware I can do expect(queryByText('The modal…

thumbsup
2
message-simple
17

create-react-app --typescript and VSCode

I created a new app using create-react-app with the --typescript flag. This generates the file src/App.tsx. When I open this file in VS Code I get lots of "problems" identified before I even change any of the generated code. The first error is on the "div" tag returned by the…

thumbsup
0
message-simple
1

Is it possible to run tests in browser somehow?

I would like to run my react-testing-library scenario in browser. So I could see or show someone how test actuality works. Something similar to cypress.

thumbsup
0
message-simple
6