Top "React-testing-library" questions

Questions about testing React components with the react-testing-library utility.

How to test a className with Jest and React testing library

I am totally new to JavaScript testing and working in a new codebase. I would like to write a test …

javascript reactjs jestjs react-testing-library
Jest mock react context

I need some help understanding how one can test an application using React Context. Here's my sample setup. context.js …

reactjs unit-testing jestjs react-context react-testing-library
Find element by id in react-testing-library

I'm using react-testing-libarary to test my react application. For some reason, I need to be able to find the element …

reactjs react-testing-library
How do you test for the non-existence of an element using jest and react-testing-library?

I have a component library that I'm writing unit tests for using Jest and react-testing-library. Based on certain props or …

reactjs jestjs react-testing-library
Get by HTML element with React Testing Library?

I'm using the getByTestId function in React Testing Library: const button = wrapper.getByTestId("button"); expect(heading.textContent).toBe("something"); Is …

react-testing-library
Check that button is disabled in react-testing-library

I have a React component that generates a button, which content contains <span> element like this one: function …

reactjs react-testing-library
Unable to find an element with the text: "myText" error when using react-testing-library

I'm trying to use react-testing-library with React and Jest but one of my tests are failing and I think it …

reactjs jestjs react-testing-library
How to query by text string which contains html tags using React Testing Library?

Current Working Solution Using this html: <p data-testid="foo">Name: <strong>Bob</strong> <…

reactjs unit-testing jestjs react-testing-library
react-testing-library why is toBeInTheDocument() not a function

Here is my code for a tooltip that toggles the CSS property display: block on MouseOver and on Mouse Out …

reactjs unit-testing jestjs react-testing-library
How to solve the "update was not wrapped in act()" warning in testing-library-react?

I'm working with a simple component that does a side effect. My test passes, but I'm getting the warning Warning: …

reactjs unit-testing jestjs react-testing-library testing-library