Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-testing-library: some portion of debug's output is not visible

I am using react jest with react testing library to test my component. I am facing a weird issue. I am usng debug return by render from testing-library.

test('component should work', async () => {   const { findByText, debug } = render(<MyComponent />);   const myElement = await findByText(/someText/i);   debug();  }); 

enter image description here

As you can see in the screenshot there are incomplete dev and closing tags for parents are missing.

like image 488
Amit Chauhan Avatar asked Jan 16 '20 05:01

Amit Chauhan


People also ask

How do I debug in React test library?

The debug method, accessible from the screen object, is a helpful tool in React Testing Library's API that allows you to see the current HTML output of components as you build out your tests. In this section, we will learn how to display the resulting DOM output of an entire component or specific elements.

How do I check if an element is disabled in React library?

Use data-test-id for <button> element. Select one of the ancestors of the <Click /> component and then select the button within(...) this scope. Click on the selected element with fireEvent and check that nothing has happened.


1 Answers

You need to change the value of DEBUG_PRINT_LIMIT env variable (default is 7000).

For example, run your tests with: DEBUG_PRINT_LIMIT=10000 yarn test

Source: https://github.com/testing-library/dom-testing-library/blob/master/src/pretty-dom.js#L24

like image 151
rrebase Avatar answered Sep 22 '22 22:09

rrebase