Skip to content

Instantly share code, notes, and snippets.

@eunsukimme
Created June 30, 2021 04:55
Show Gist options
  • Save eunsukimme/ce651415d108a657ff313c3f8509002e to your computer and use it in GitHub Desktop.
Save eunsukimme/ce651415d108a657ff313c3f8509002e to your computer and use it in GitHub Desktop.
setup / teardown configuration for test code
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