score:0

Accepted answer

enzyme exists applies to nodes only , it's not a trivial task to check that a prop exists and there's no dedicated way to do this.

a way to check that a prop exists:

expect(wrapper.find('button').at(3).props()).tohaveproperty('onclick');

a way to check that a prop exists and is defined:

expect(wrapper.find('button').at(3).props('onclick')).not.tobeundefined();

a correct way to write this test is to assert what exactly the prop should be, i.e. a function:

expect(wrapper.find('button').at(3).props('onclick')).toequal(expect.any(function));

Related Query

More Query from same tag