From 2d1d1e67c5dd0992338622adf90f2270b05f2192 Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Sat, 11 Feb 2023 16:27:25 +0100 Subject: [PATCH] repro: #1973 --- src/mount.ts | 4 +++- tests/components/DefinePropsAndDefineEmits.vue | 15 +++++++++++++++ tests/mount.spec.ts | 12 ++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/components/DefinePropsAndDefineEmits.vue diff --git a/src/mount.ts b/src/mount.ts index f8206294fb..34b5e707eb 100644 --- a/src/mount.ts +++ b/src/mount.ts @@ -203,7 +203,9 @@ export function mount< > > // component declared by vue-tsc ScriptSetup -export function mount>( +export function mount< + T extends DefineComponent +>( component: T, options?: ComponentMountingOptions ): VueWrapper> diff --git a/tests/components/DefinePropsAndDefineEmits.vue b/tests/components/DefinePropsAndDefineEmits.vue new file mode 100644 index 0000000000..93b1cf6ee1 --- /dev/null +++ b/tests/components/DefinePropsAndDefineEmits.vue @@ -0,0 +1,15 @@ + + + diff --git a/tests/mount.spec.ts b/tests/mount.spec.ts index 7c77d66c45..59044df754 100644 --- a/tests/mount.spec.ts +++ b/tests/mount.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import { defineComponent } from 'vue' import { mount } from '../src' +import DefinePropsAndDefineEmits from './components/DefinePropsAndDefineEmits.vue' import HelloFromVitestPlayground from './components/HelloFromVitestPlayground.vue' describe('mount: general tests', () => { @@ -32,4 +33,15 @@ describe('mount: general tests', () => { expect(spy).not.toHaveBeenCalled() }) + + it('should not warn on readonly hasOwnProperty when mounting a component', () => { + const wrapper = mount(DefinePropsAndDefineEmits, { + props: { + placement: 'end' + }, + slots: { default: 'Hello' } + }) + expect(wrapper.get('div').text()).toContain('Hello') + expect(wrapper.get('div').classes()).toContain('end') + }) })