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..fa09163229 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 mount a component with props, emits and slot (#1973)', () => { + const wrapper = mount(DefinePropsAndDefineEmits, { + props: { + placement: 'end' + }, + slots: { default: 'Hello' } + }) + expect(wrapper.get('div').text()).toContain('Hello') + expect(wrapper.get('div').classes()).toContain('end') + }) })