Testing Recipes - Timers: call useFakeTimers/userRealTimers before/after each test (#3591)

This commit is contained in:
Pradip
2021-03-23 09:59:26 +01:00
committed by GitHub
parent f5784cb138
commit 8aee286cc8

View File

@@ -465,13 +465,12 @@ import { act } from "react-dom/test-utils";
import Card from "./card";
jest.useFakeTimers();
let container = null;
beforeEach(() => {
// setup a DOM element as a render target
container = document.createElement("div");
document.body.appendChild(container);
jest.useFakeTimers();
});
afterEach(() => {
@@ -479,6 +478,7 @@ afterEach(() => {
unmountComponentAtNode(container);
container.remove();
container = null;
jest.useRealTimers();
});
it("should select null after timing out", () => {