Browse Source

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

main
Pradip 4 years ago
committed by GitHub
parent
commit
8aee286cc8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      content/docs/testing-recipes.md

4
content/docs/testing-recipes.md

@ -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", () => {

Loading…
Cancel
Save