For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/testing-library/event-reference.md.

Event reference

Every event fireEvent has a method for, and the template binding each one runs.

fireEvent.tap(element); // runs (bindtap) or (catchtap), then the ancestors'
fireEvent.input(element, { detail: { value: 'hello' } }); // $event.detail.value

Each method takes the element and an optional init object. It runs the element's (bind*) or (catch*) handler. Touch, mouse and key events then go up to the page, as on a device, until a (catch*) handler or a handler that calls $event.stopPropagation() stops them. The other events stay on the element, as do mouseenter and mouseleave.

As on a device, every (global-bind*) handler for the event runs first, wherever it is in the page. They're how document: and window: listeners hear touches, so those run too, after the elements' handlers. One that a (catch*) handler stopped reaches them on the next timer:

fireEvent.tap(menuItem); // a (catchtap)
await waitForUpdate(); // the component's (document:click) has run

$event.target is the element, as a device names it: { uid }, its unique id.

Touch

MethodBinding
fireEvent.tap(bindtap)
fireEvent.longpress(bindlongpress)
fireEvent.longtap(bindlongtap)
fireEvent.touchstart(bindtouchstart)
fireEvent.touchmove(bindtouchmove)
fireEvent.touchend(bindtouchend)
fireEvent.touchcancel(bindtouchcancel)

Mouse and keyboard

MethodBinding
fireEvent.mousedown(bindmousedown)
fireEvent.mouseup(bindmouseup)
fireEvent.mousemove(bindmousemove)
fireEvent.mouseclick(bindmouseclick)
fireEvent.mousedblclick(bindmousedblclick)
fireEvent.mouselongpress(bindmouselongpress)
fireEvent.wheel(bindwheel)
fireEvent.mouseenter(bindmouseenter)
fireEvent.mouseleave(bindmouseleave)
fireEvent.keydown(bindkeydown)
fireEvent.keyup(bindkeyup)

Scrolling

MethodBinding
fireEvent.scroll(bindscroll)
fireEvent.scrollend(bindscrollend)
fireEvent.scrolltoupper(bindscrolltoupper)
fireEvent.scrolltolower(bindscrolltolower)
fireEvent.scrolltoupperedge(bindscrolltoupperedge)
fireEvent.scrolltoloweredge(bindscrolltoloweredge)
fireEvent.scrolltonormalstate(bindscrolltonormalstate)
fireEvent.contentsizechanged(bindcontentsizechanged)

Coming into view

MethodBinding
fireEvent.uiappear(binduiappear)
fireEvent.uidisappear(binduidisappear)

A device sends uiappear when an element comes into view, and uidisappear when it leaves. The lynxExposure directive and IntersectionObserver listen for them, so firing one is how a test scrolls an element into view. An IntersectionObserver given a threshold, rootMargin, scrollMargin or root sees all of the element come in (an intersectionRatio of 1) and all of it leave, as there's no layout to measure in a test:

fireEvent.uiappear(frame);
await waitForUpdate();

Forms and focus

MethodBinding
fireEvent.input(bindinput)
fireEvent.confirm(bindconfirm)
fireEvent.focus(bindfocus)
fireEvent.blur(bindblur)
fireEvent.keyboardheightchange(bindkeyboardheightchange)

A focused <input> or <textarea> fires keyboardheightchange as the keyboard shows, changes size and hides. Pass its height as detail.height, and 0 for a keyboard that went away:

fireEvent.keyboardheightchange(field, { detail: { height: 336 } });
await waitForUpdate();

Accessibility

MethodBinding
fireEvent.accessibilityaction(bindaccessibilityaction)

A screen reader user picking one of an element's accessibility-actions fires accessibilityaction, with the action's name in detail.name:

fireEvent.accessibilityaction(row, { detail: { name: 'Delete' } });

Overlays

MethodBinding
fireEvent.requestclose(bindrequestclose)

Android's back button fires requestclose at an open <overlay>, which has no detail.

Layout and loading

MethodBinding
fireEvent.layoutchange(bindlayoutchange)
fireEvent.load(bindload)
fireEvent.error(binderror)
fireEvent.bgload(bindbgload)
fireEvent.bgerror(bindbgerror)

An <image>, <svg>, <frame> or <webview> fires load once its content arrives, and an <image>, <video>, <webview> or <overlay> fires error when it fails. Pass what the element would report as detail, such as an image's size:

fireEvent.load(image, { detail: { width: 240, height: 340 } });
await waitForUpdate();

Animations and transitions

MethodBinding
fireEvent.transitionstart(bindtransitionstart)
fireEvent.transitionend(bindtransitionend)
fireEvent.transitioncancel(bindtransitioncancel)
fireEvent.animationend(bindanimationend)

Other events

For an event without a method, create it yourself. Its type is the binding's event type and the event name, joined by a colon:

fireEvent(element, new Event('bindEvent:change')); // runs (bindchange)

A CustomEvent's detail reaches the handler as $event.detail. A <viewpager> that moved to its third page:

fireEvent(
  pager,
  new CustomEvent('bindEvent:change', {
    detail: { index: 2, isDragged: true },
  }),
);