diff --git a/src/vueWrapper.ts b/src/vueWrapper.ts index b69bc85da..67c1f4864 100644 --- a/src/vueWrapper.ts +++ b/src/vueWrapper.ts @@ -213,7 +213,7 @@ export class VueWrapper< } } - get element(): Element { + get element(): T['$el'] { // if the component has multiple root elements, we use the parent's element return this.hasMultipleRoots ? this.parentElement : this.vm.$el } diff --git a/test-dts/wrapper.d-test.ts b/test-dts/wrapper.d-test.ts index 1582f3d95..4c25fabf0 100644 --- a/test-dts/wrapper.d-test.ts +++ b/test-dts/wrapper.d-test.ts @@ -14,6 +14,16 @@ const domWrapper = wrapper.find('#other') let inputMaybe = wrapper.find('input') expectType(inputMaybe.element) +let buttonComp = mount( + defineComponent({ template: '' }) +) +expectType(buttonComp.element) + +let multiRootComp = mount(defineComponent({ template: '' })) +// this will be a wrapper div element like so:
+expectType(multiRootComp.element) +expectType(multiRootComp.element.firstElementChild) + // SVG element selector let lineMaybe = wrapper.find('line') expectType(lineMaybe.element)