Created
June 30, 2021 04:55
-
-
Save eunsukimme/ce651415d108a657ff313c3f8509002e to your computer and use it in GitHub Desktop.
setup / teardown configuration for test code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { unmountComponentAtNode } from "react-dom"; | |
let container = null; | |
beforeEach(() => { | |
// 렌더링 컨테이너로 활용하기 위한 DOM element 를 생성합니다 | |
container = document.createElement("div"); | |
document.body.appendChild(container); | |
}); | |
afterEach(() => { | |
// 각 테스트를 수행한 뒤 마운트된 컨테이너를 클린업 합니다 | |
unmountComponentAtNode(container); | |
container.remove(); | |
container = null; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment