I have implemented a focus listener in my component like so (as shown in the react-navigation v5 documentation):
componentDidMount() {
const { navigation } = this.props
this._unsubscribeFocus = navigation.addListener('focus', () => {
// do something
})
}
I am struggling with finding a way to write a unit test for this using Jest/ Enzyme. I have tried using wrapper.simulate('focus') however, this doesn't seem to make the callback run.
Does anyone have any ideas/ experience with testing this?