Categories
React Answers

How to pass an event object to enzyme .simulate?

Spread the love

To pass an event object to enzyme .simulate, we call simulate with a 2nd argument.

For instance, we write

const mockedEvent = { target: {} };
checkbox.find("input").simulate("click", mockedEvent);

to call simulate with the event object as the 2nd argument

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *