From fb36908120b63d699be8447edc49b0ab623d5552 Mon Sep 17 00:00:00 2001 From: ced Date: Mon, 14 Nov 2022 14:29:18 +0100 Subject: [PATCH] repro: 'set' on proxy: trap returned falsish for property with Vue v3.2.45 This comes from the fact that mocks are set via a mixin (Options API) and we run into the more strict behavior of Vue v3.2.45 introduced in https://github.com/vuejs/core/commit/f73925d76a76ee259749b8b48cb68895f539a00f#diff-ea4d1ddabb7e22e17e80ada458eef70679af4005df2a1a6b73418fec897603ceR404 --- tests/components/ScriptSetup.vue | 2 +- tests/expose.spec.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) 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') + }) })