Skip to content

Commit

Permalink
Testing Recipes - Timers: call useFakeTimers/userRealTimers before/af…
Browse files Browse the repository at this point in the history
…ter each test (reactjs#3591)
  • Loading branch information
Pradip-Khakurel authored Mar 23, 2021
1 parent f5784cb commit 8aee286
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions content/docs/testing-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,20 +465,20 @@ 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(() => {
// cleanup on exiting
unmountComponentAtNode(container);
container.remove();
container = null;
jest.useRealTimers();
});
it("should select null after timing out", () => {
Expand Down

0 comments on commit 8aee286

Please sign in to comment.