diff --git a/tests/components/ScriptSetup.vue b/tests/components/ScriptSetup.vue index d79d16ab5c..48402e8067 100644 --- a/tests/components/ScriptSetup.vue +++ b/tests/components/ScriptSetup.vue @@ -12,6 +12,6 @@ const inc = () => { diff --git a/tests/expose.spec.ts b/tests/expose.spec.ts index 2b09247bfb..486660dfb7 100644 --- a/tests/expose.spec.ts +++ b/tests/expose.spec.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from 'vitest' +import { describe, expect, it, vi } from 'vitest' import { nextTick } from 'vue' import { mount } from '../src' import Hello from './components/Hello.vue' @@ -61,4 +61,21 @@ describe('expose', () => { await nextTick() expect(wrapper.html()).toContain('2') }) + + it('should not throw when mocking', async () => { + const spiedIncrement = vi.fn() + const wrapper = mount(ScriptSetup, { + global: { + mocks: { + inc: spiedIncrement + } + } + }) + + await wrapper.find('button').trigger('click') + await nextTick() + + expect(spiedIncrement).toHaveBeenCalled() + expect(wrapper.html()).toContain('0') + }) })