2

When rendering a plain HTML code with @testing-library/react, the output HTML adds many empty lines to the input HTML(have a look at the code after toMatchInlineSnapshot ).

How can I get rid of this? I just want to get the HTML as it is.

import React from "react";
import { render } from '@testing-library/react'
const html = `
<div
  class="hello"
>
  <p>
    How do you do!
  </p>
</div>
`;
it("renders correctly", async () => {
  expect(await render(<div dangerouslySetInnerHTML={{ __html: html }} />).baseElement)
    .toMatchInlineSnapshot(`
    <body>
      <div>
        <div>
          

          <div
            class="hello"
          >
            
      
            <p>
              
        How do you do!
      
            </p>
            

          </div>
          

        </div>
      </div>
    </body>
  `);
});
banyudu
  • 1,046
  • 9
  • 19

0 Answers0