Skip to content

Commit 8dd20bc

Browse files
dbismutKent C. Dodds
authored and
Kent C. Dodds
committed
Add documentation for createEvent (#109)
1 parent f0bc9ed commit 8dd20bc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/dom-testing-library/api-events.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,20 @@ fireEvent.keyDown(domNode, { key: 'A', code: 65, charCode: 65 })
7676

7777
You can find out which key code to use at
7878
[https://keycode.info/](https://keycode.info/).
79+
80+
## `createEvent[eventName]`
81+
82+
```typescript
83+
createEvent[eventName](node: HTMLElement, eventProperties: Object)
84+
```
85+
86+
Convenience methods for creating DOM events that can then be fired by
87+
`fireEvent`, allowing you to have a reference to the event created: this might
88+
be useful if you need to access event properties that cannot be initiated
89+
programmatically (such as `timeStamp`).
90+
91+
```javascript
92+
const myEvent = createEvent.click(node, { button: 2 })
93+
fireEvent(node, myEvent)
94+
// myEvent.timeStamp can be accessed just like any other properties from myEvent
95+
```

0 commit comments

Comments
 (0)