I've tried:
input.simulate('blur');
and
input.simulate('onBlur');
None of these work. Is this even available in Enzyme (I'm using version 2.4.1).
The onblur attribute fires the moment that the element loses focus. Onblur is most often used with form validation code (e.g. when the user leaves a form field).
The onBlur event handler is called when focus has left the element (or left some element inside of it). For example, it's called when the user clicks outside of a focused text input. function Example() { return ( <input onBlur={(e) => { console.
A blur event fires when an element has lost focus. Note: As the blur event is executed synchronously also during DOM manipulations (e.g. removing a focussed input), AngularJS executes the expression using scope.
input.simulate('focus')
, input.simulate('change')
and input.simulate('blur')
should work. Check if your input is actually a node declared as _wrapper.find('input')
and exists. Secondly, there's another question similar to this one: Enzyme - How to access and set <input> value? And finally if you check the source code of the ReactWrapper component then you will find that it uses all events that React can recognize. So the error is somewhere in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With