I have the following lines in my test (using react and enzyme):
const input = mount(<MyComponent/>).find('input').node;
input.focus();
input.select();
I have upgraded enzyme from v2 to v3, and now it throws the following error:
Attempted to access ReactWrapper::node, which was previously a private property on Enzyme ReactWrapper instances, but is no longer and should not be relied upon. Consider using the getElement() method instead.
However, when I use getElement()
like suggested in the error, like so:
const input = mount(<MyComponent/>).find('input').getElement();
The resulting object doesn't have the functions that were in the original .node
:
TypeError: (0 , _enzyme.mount)(...).find(...).getElement(...).focus is not a function
TypeError: (0 , _enzyme.mount)(...).find(...).getElement(...).select is not a function
What should I use instead of .node
and .getElement()
to make this code work in enzyme 3?