Skip to content

Commit 314ab4f

Browse files
callumacraeeddyerburgh
authored andcommitted
docs: clarified emitted() return object in docs (#253)
1 parent af88abb commit 314ab4f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/en/api/wrapper/emitted.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ expect(wrapper.emitted('foo').length).toBe(2)
4444
// assert event payload
4545
expect(wrapper.emitted('foo')[1]).toEqual([123])
4646
```
47+
48+
The `.emitted()` method returns the same object every time it is called, not a new one, and so the object will update when new events are fired:
49+
50+
```js
51+
const emitted = wrapper.emitted()
52+
53+
expect(emitted.foo.length).toBe(1)
54+
55+
// do something to make `wrapper` emit the "foo" event
56+
57+
expect(emitted.foo.length).toBe(2)
58+
```

0 commit comments

Comments
 (0)