React Testing Library · Function
cleanup
cleanup unmounts React trees created by render and clears the DOM. It runs automatically after each test when the test framework provides a global afterEach hook; otherwise, call it yourself.
Last updated
Syntax
cleanup()In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
renderafterEach@testing-library/react/pure@testing-library/react/dont-cleanup-after-eachRTL_SKIP_AUTO_CLEANUP