- <ReactTestRenderer> with event <string> <assertion?>
- <ReactTestRenderer> with event <string> <object> <assertion?>
with event .... [
with event can trigger events in the shallow, full and test renderers. For the normal full renderer,
TestUtils.Simulate is used to simulate the event. For the shallow and test renderers, it is expected that
there is a prop with the name
on[EventName], where the first letter of the event is capitalised.
e.g. with a button that counts its own clicks
Also note that due to unexpected's clever string handling, you can often concatenate the
with event and the
Given the following todo list:
If you want to trigger an event on a specific component, (i.e. not the top level component), use
after the event.
To pass arguments to the event, simply include the event object after the event name
This will call the function passed in the
onMouseDown prop of the
You can take the renderer after the event has been triggered by using the promise returned
expect. This is often used to test that spy or mock callbacks have been called (using for instance sinon.js).
You can add an
eventTarget prop to the expected to trigger the event on a child component.