Skip to content

Instantly share code, notes, and snippets.

@SebinLee
Created May 28, 2020 05:53
Show Gist options
  • Save SebinLee/b87aed664e2c5fe08b9f05b5f725b765 to your computer and use it in GitHub Desktop.
Save SebinLee/b87aed664e2c5fe08b9f05b5f725b765 to your computer and use it in GitHub Desktop.
React Testing Recipe 번역 - Setup/Teardown
import { unmountComponentAtNode } from "react-dom";
let container = null;
beforeEach(() => {
// 렌더 타겟으로 사용할 DOM 요소를 생성합니다.
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