# `PhoenixTestJsdom.FireEvent`
[🔗](https://github.com/ziinc/phoenix_test_jsdom/blob/v0.1.2/lib/phoenix_test_jsdom/fire_event.ex#L1)

Fires DOM events on elements inside a JSDom-mounted LiveView, mirroring
[dom-testing-library](https://github.com/testing-library/dom-testing-library)'s
`fireEvent.<eventName>` API.

Event names are extracted at compile time directly from the installed
`@testing-library/dom` package (via a short Node invocation), so the list
stays in sync automatically with whichever version is in `priv/node_modules`.

## Usage

    import Phoenix.LiveViewTest, only: [element: 2, element: 3]
    alias PhoenixTestJsdom.FireEvent

    view
    |> FireEvent.mouse_down(element(view, "button#menu"))
    |> FireEvent.key_down(element(view, "input"), %{key: "Enter", code: "Enter"})
    |> FireEvent.change(element(view, "input[name=email]"), %{target: %{value: "a@b.com"}})
    |> PhoenixTestJsdom.render()

The third argument merges on top of the event's `defaultInit`. The special
key `:target` (a map) is applied as element property assignments *before*
dispatch, which is how RTL's `change(el, { target: { value: "x" } })` works.

All functions return the `view` for pipeability. Use `PhoenixTestJsdom.render/1`
afterwards to see the updated HTML.

For custom or non-standard events, use the generic `fire/4`:

    FireEvent.fire(view, element(view, "#my-el"), "my-custom-event", %{detail: 42})

## Attribution

Event names and defaults are taken from
[dom-testing-library](https://github.com/testing-library/dom-testing-library)
(MIT License, Copyright (c) 2018 Kent C. Dodds).

# `abort`

# `animation_end`

# `animation_iteration`

# `animation_start`

# `blur`

# `can_play`

# `can_play_through`

# `change`

# `click`

# `composition_end`

# `composition_start`

# `composition_update`

# `context_menu`

# `copy`

# `cut`

# `dbl_click`

# `double_click`

# `drag`

# `drag_end`

# `drag_enter`

# `drag_exit`

# `drag_leave`

# `drag_over`

# `drag_start`

# `drop`

# `duration_change`

# `emptied`

# `encrypted`

# `ended`

# `error`

# `fire`

Fires an arbitrary named DOM event on the resolved element.

Useful for custom events or any event not in dom-testing-library's event map.

# `focus`

# `focus_in`

# `focus_out`

# `got_pointer_capture`

# `input`

# `invalid`

# `key_down`

# `key_press`

# `key_up`

# `load`

# `load_start`

# `loaded_data`

# `loaded_metadata`

# `lost_pointer_capture`

# `mouse_down`

# `mouse_enter`

# `mouse_leave`

# `mouse_move`

# `mouse_out`

# `mouse_over`

# `mouse_up`

# `offline`

# `online`

# `page_hide`

# `page_show`

# `paste`

# `pause`

# `play`

# `playing`

# `pointer_cancel`

# `pointer_down`

# `pointer_enter`

# `pointer_leave`

# `pointer_move`

# `pointer_out`

# `pointer_over`

# `pointer_up`

# `pop_state`

# `progress`

# `rate_change`

# `reset`

# `resize`

# `scroll`

# `seeked`

# `seeking`

# `select`

# `stalled`

# `submit`

# `suspend`

# `time_update`

# `touch_cancel`

# `touch_end`

# `touch_move`

# `touch_start`

# `transition_cancel`

# `transition_end`

# `transition_run`

# `transition_start`

# `volume_change`

# `waiting`

# `wheel`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
