Category "react-testing-library"

How to test for document being undefined with RTL?

I have the following react hook which brings focus to a given ref and on unmount returns the focus to the previously focused element. export default function u

React-testing-library: changes due to input

I'm trying to test that a component updates as it should due to changes in an input element. I use the fireEvent.change()-function, and if I then check the valu

@testing-library/react render Error: `target` and `targetRef` props are `undefined`, it' required to use one of them

I am trying to write a unit test for a custom react component that use the Dialog from @fluentui/react-northstar when I try to render the component from the tes

React testing library, how to open a Collapse in Ant Design

I want to write a unit test that opens an antd. Collapse <Panel /> But no matter what combination of fireEvent or userEvent mouse actions I try, I cannot

how to implement page navigation in react testing library (Link, a tag, history.push)

I am trying perform Dom testing at '/test' url page. my application use BrowseRouter from react-router-dom As following user approach, I want to manually chang

react-dom installed, but not found. `Could not find module in path: 'react-dom/client' relative to`

Here is the Codesandbox I want to run a rest, but the Tests tab shows this error. Could not find module in path: 'react-dom/client' relative to '/node_modules/@

React redux toolkit testing with jest, how to dispatch asyncthunk and the state?

I want to write unit test which checks if data (onLoad) from dispatching async thunk is delivered into state. It's first time when i'm writing unit tests and it

Simplest test for react-router's Link with @testing-library/react

I'm trying to understand how to best test that react-router behaves as expected with @testing-library/react. The simplest test I can think of, is to verify tha

How to test Material UI v5 components with sx props in @testing-library/react?

React Testing Library does not apply sx props of Material UI components during rendering. For example, I specify properties to hide an element at certain breakp

How to pass a an argument to getByText in react Testing Library?

Currently I'm doing this getByText(/SomeText/i); But I want to make a function and pass some text as an argument by first storing it in a variable. I tried doi

Webpack 5 & Jest - Property 'toBeInTheDocument' does not exist on type 'JestMatchers<HTMLElement>'

I can't get the typings for Jest to work with Webpack 5 and TypeScript, I've tried other solutions for the same problem. The problem is only with "screen" and "

Webpack 5 & Jest - Property 'toBeInTheDocument' does not exist on type 'JestMatchers<HTMLElement>'

I can't get the typings for Jest to work with Webpack 5 and TypeScript, I've tried other solutions for the same problem. The problem is only with "screen" and "