Skip to content

Commit 8aee286

Browse files
Testing Recipes - Timers: call useFakeTimers/userRealTimers before/after each test (#3591)
1 parent f5784cb commit 8aee286

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/docs/testing-recipes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,20 +465,20 @@ import { act } from "react-dom/test-utils";
465465
466466
import Card from "./card";
467467
468-
jest.useFakeTimers();
469-
470468
let container = null;
471469
beforeEach(() => {
472470
// setup a DOM element as a render target
473471
container = document.createElement("div");
474472
document.body.appendChild(container);
473+
jest.useFakeTimers();
475474
});
476475
477476
afterEach(() => {
478477
// cleanup on exiting
479478
unmountComponentAtNode(container);
480479
container.remove();
481480
container = null;
481+
jest.useRealTimers();
482482
});
483483
484484
it("should select null after timing out", () => {

0 commit comments

Comments
 (0)