I\'m trying to simulate a keyDown
event, specifically for Enter, keyCode: 13
. I\'ve tried a number of different ways of doing this, but none of them ar
Simulate solution is deprecated
Enzyme simulate is supposed to be removed in version 4. Main maintainer is suggesting directly invoking prop functions. One solution is to directly test that invoking those props does the right thing; or you can mock out instance methods, test that the prop functions call them and unit test the instance methods.
You could call key down for example
wrapper.find('input').prop('onKeyDown')({ key: 'Enter' })
or
wrapper.find('input').props().onKeyDown({ key: 'Enter' })
Information about deprecation: https://github.com/airbnb/enzyme/issues/2173