Closed
Description
Describe the Feature
I'm testing hooks that modify the global state of a library, so they need to be unmounted before the next test begins. Currently, I'm using this workaround:
import { render as renderImpl, RenderAPI } from 'react-native-testing-library'
const rendered: RenderAPI[] = []
const render: typeof renderImpl = (...args) => {
const elem = renderImpl(...args)
rendered.push(elem)
return elem
}
beforeEach(() => {
rendered.forEach(elem => elem.unmount())
rendered.length = 0
})
Ideally, react-native-testing-library
would export a function that lets developers opt-in to this behavior, like the following:
import { setAutoUnmount } from 'react-native-testing-library'
setAutoUnmount(true)
Then I wouldn't need to maintain this code myself. :)
Possible Implementations
See the workaround.
Related Issues
None.
Metadata
Metadata
Assignees
Labels
No labels