DEV Community

Discussion on: Creating a React component with TDD

Collapse
zaboco profile image
Bogdan Zaharia

One thing that might help is too replace the expect(foo).toBeInTheDocument() with text assertion on elements. For example:

expect(getByRole('heading')).toHaveTextContent('Confirmation')
Enter fullscreen mode Exit fullscreen mode

This way, when there is an error, a typo for example, the output is more focused:

Expected element to have text content:
  Confirmation
Received:
  Confimation
Enter fullscreen mode Exit fullscreen mode