React-testing-library: The debug command is not printing the entire component.

Created on 14 Oct 2019  路  6Comments  路  Source: testing-library/react-testing-library

  • react-testing-library version: 9.2.0
  • react version: 16.8.1
  • node version: 11.6.0
  • npm (or yarn) version: 6.9.0

Relevant code or config:

it("should render the component", async () => {
    const { debug, getByTestId } = render(
      <Component
        navigate={() => {}}
        location={{ search: "" }}
        setError={() => {}}
        setException={() => {}}
      />
    );
    await wait();
    debug();
});

What you did:

I'm just testing a component and doing a debug of the component

What happened:

The debug that was printed was just half of what I was expecting.

image

Reproduction:

Problem description:

The Debug is not printing the entire component, I think it is probably something related to the terminal.

Suggested solution:

Most helpful comment

It should ideally be an option of the debug() command instead. For googlers: the limit is in number of chars, not lines, the default is 7000. So you may need smth like "20000" for instance

All 6 comments

Output is truncated

https://testing-library.com/docs/dom-testing-library/api-helpers#debugging

Set the env var DEBUG_PRINT_LIMIT to increase the limit

Thanks mate!

It should ideally be an option of the debug() command instead. For googlers: the limit is in number of chars, not lines, the default is 7000. So you may need smth like "20000" for instance

Wow it took me so long to realize that my output was getting truncated... I was very confused as to why my component wasn't rendering properly. and now that i've realized it I agree with @eric-burel that this should be an option of debug().

I would argue that the default should be extremely high (or set to infinity) as setting an env var to increase this is strange and not intuitive. At least an optional param as @eric-burel mentions would be a big step forward.

So as I was looking over this again, I realized that debug() is built on top of prettyDom and DOES have optional parameters including one for maxLength.

So if you do screen.debug(null, 20000) then it will print as expected, based on the documentation of that function.

Was this page helpful?
0 / 5 - 0 ratings