I am testing a vue component with cypress. For my application I am using a global EventBus as described here.
My EventBus.js looks like that:
import Vue from 'vue';
export const EventBus = new Vue();
console.log(EventBus);
The vue component I am testing listens for events on this event bus to show data. In my test I am calling:
EventBus.$on("Event-name", event => {
//listen on events
});
The data is not getting shown in my component. The problem is probably that there are two EventBusses created instead of one. When logging the EventBus I get:
Vue {_uid: 0, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: Vue, …}
Before my test starts to run. And the following is the EventBus after the tests have started.
Vue {_uid: 2, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: Vue, …}
The console.log is written inside the EventBus.js file, which contains the global EventBus. The uid is different, so I guess Vue created a new EventBus.
How do I get it to work?
Aucun commentaire:
Enregistrer un commentaire