Browse Source
Testing Recipes - Timers: call useFakeTimers/userRealTimers before/after each test (#3591)
main
Pradip
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
2 deletions
-
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", () => { |
|
|
|