// hello.test.js, againimport React from "react";import { render, unmountComponentAtNode } from "react-dom";import { act } from "react-dom/test-utils";import pretty from "pretty";import Hello from "./hello";let container = null;beforeEach(() => { // setup a DOM element as a render target
container = document.createElement("div");
document.body.appendChild(container);});afterEach(() => { // cleanup on exiting
unmountComponentAtNode(container);
container.remove();
container = null;});it("should render a greeting", () => {
act(() => {
render(, container);
});
expect(
pretty(container.innerHTML)
).toMatchInlineSnapshot(); /* ... gets filled automatically by jest ... */
act(() => {
render(, container);
});
expect(
pretty(container.innerHTML)
).toMatchInlineSnapshot(); /* ... gets filled automatically by jest ... */
act(() => {
render(, container);
});
expect(
pretty(container.innerHTML)
).toMatchInlineSnapshot(); /* ... gets filled automatically by jest ... */});