'TypeError: Cannot read properties of undefined (reading 'pop') JS Testing Error
Hello I am trying to test my JavaScript Project and am trying to test to make sure this one button works in the code and I am getting this error that I cannot find any answers on. I cannot figure out why reading pop is undefined
Error Message
TypeError: Cannot read properties of undefined (reading 'pop')
30 | </TopContainer>
31 | <NavContainer >
> 32 | <BackLogoButton id="backButton" onPress={() => navigation.pop(1)}>
| ^
33 | <BackLogo source={require('./../assets/back-logo.png')}/>
34 | </BackLogoButton>
35 | </NavContainer>
Test Code
describe('Tests the BackLogoButton in Tutorial pages', () => {
it('BackLogoButton is pressable', () => {
const onPressEvent = jest.fn();
const wrapper = shallow(<BackLogoButton onPress={onPressEvent}/>);
onPressEvent.mockReturnValue('');
wrapper.find('#backButton').first().props().onPress();
expect(onPressEvent.mock.calls.length).toBe(0);
});
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
