Using @react-navigation/stack
library in my project, while doing unit testing (using jest) I am getting this error
Couldn't find the header height. Are you inside a screen in Stack?
index.spec.js
it('should have a title and subtitle', () => {
const { getByText } = render(<Otp {...props} />); });
Otp component
<SafeAreaView style={styles.mainContainer}>
<KeyboardAvoidingView
keyboardVerticalOffset={useHeaderHeight()} --> getting error at this line
>
<Text>...</Text>
</KeyboardAvoidingView>
</SafeAreaView>
Also tried a solution in which I mocked a navigator but got no success.