API for testing emitted events
See original GitHub issueRelated to TODO in #4
Some ideas
// Creates listener on the component
wrapper.listenTo('event', spy)
// returns array of events that have been emitted
wrapper.events
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (9 by maintainers)
Top Results From Across the Web
emitted | Vue Test Utils
Return an object containing custom events emitted by the Wrapper vm . Returns: { [name: string]: Array<Array<any>> }. Example:.
Read more >Testing emitted events - Vue Testing Handbook
vue-test-utils provides an emitted API which allows us to make assertions on emitted events. The documentation for emitted is found here .
Read more >Testing Emitted Events - Unit Testing Vue 3 - Vue Mastery
Learn how to test that your component's custom events were emitted with the correct payload. Unlock this lesson by subscribing to a plan....
Read more >API | Testing Library
Vue Testing Library re-exports everything from DOM Testing Library. ... inner value while emitting the appropriate native event.
Read more >What is the best way to test if an event is being emitted to ...
For example, if I have a metric called “Page Viewed” and in my code I run the method ampli.pageViewed(params), after running that method...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reopen as I am revisiting this feature. After having to manually create spies for all the events I wanted to assert, it felt quite tedious. I am proposing an API that requires minimal setup by simply auto-recording all emitted events in a
wrapper.emitted
object.Say you emit the following events:
Then
wrapper.emitted
would look like this:This simple data structure allows all kinds of assertions:
The best part is you don’t need to do any wiring or setup, you can just assert it after you trigger the events.
/cc @eddyerburgh @codebryo
What about making it
wrapper.on
to be consistent withvm.$on
? It seems to be just an alias.