How to Test a Global Event Bus With Vue Test Utils? : <p>I am trying to learn how to test events emitted through a global Event Bus. Here's the code with some comments in the places I don't know what to do.</p>

<pre class="lang-js prettyprint-override"><code>// EvtBus.js
import Vue from 'vue';
export const EvtBus = new Vue();
</code></pre>

<pre class="lang-html prettyprint-override"><code>&lt;!-- CouponCode.vue --&gt;
&lt;template&gt;
    &lt;div&gt;
        &lt;input
            class="coupon-code"
            type="text"
            v-model="code"
            @input="validate"&gt;
        &lt;p v-if="valid"&gt;
            Coupon Redeemed: {{ message }}
        &lt;/p&gt;
    &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;

import { EvtBus } from '../EvtBus.js';

export default {
    data () {
        return {
            code: '',
            valid: false,

            coupons: [
                {
                    code: '50OFF',
                    discount: 50,
                    message: '50% Off!'
                },
                {
                    code: 'FREE',
                    discount: 100,
                    message: 'Entirely Free!'
                }
            ]
        };
    },

    created () {
        EvtBus.$on('coupon-applied', () =&gt; {
            //console.info('had a coupon applied event on component');
        });
    },

    methods: {
        validate () {
            // Extract the coupon codes into an array and check if that array
            // includes the typed in coupon code.
            this.valid = this.coupons.map(coupon =&gt; coupon.code).includes(this.code);
            if (this.valid) {
                this.$emit('applied');
                // I NEVER see this on the coupon-code.spec.js
                EvtBus.$emit('coupon-applied');
            }
        }
    },

    computed: {
        message () {
            return this.coupons.find(coupon =&gt; coupon.code === this.code).message;
        }
    }
}
&lt;/script&gt;
</code></pre>

<pre class="lang-js prettyprint-override"><code>// tests/coupon-code.spec.js
import expect from 'expect';
import { mount } from '@vue/test-utils';
import CouponCode from '../src/components/CouponCode.vue';
import { EvtBus } from '../src/EvtBus.js';

describe('Reminders', () =&gt; {
    let wrp;

    beforeEach(() =&gt; {
        wrp = mount(CouponCode);
    });

    it('broadcasts the percentage discount when a valid coupon code is applied', () =&gt; {
        let code = wrp.find('input.coupon-code');
        code.element.value = '50OFF';
        code.trigger('input');

        console.log(wrp.emitted('applied'));

        //
        // I NEVER see this on the outpout.
        // How can I test it through a global event bus rather than
        // an event emitted from the component instance?
        //
        EvtBus.$on('coupon-applied', () =&gt; {
            console.log('coupon was applied through event bus');
        });

        // Passes, but not using EvtBus instance.
        expect(wrp.emitted('applied')).toBeTruthy;

    });
});
</code></pre>

<p>So, my doubt is how to test that the global event bus is emitting and listening to events inside components that use that event bus.</p>

<p>So, is it possible to test the global Event Bus using Vue Test Utils or I should use another approach?</p>
