diff --git a/docs/api/index.md b/docs/api/index.md index d3fd11000..a5826c6e2 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -1096,8 +1096,12 @@ Finds a Vue Component instance and returns a `VueWrapper` if found. Returns `Err **Signature:** ```ts -findComponent(selector: new () => T): VueWrapper -findComponent(selector: FindComponentSelector): VueWrapper +findComponent(selector: string): WrapperLike +findComponent(selector: T | Exclude): VueWrapper> +findComponent(selector: T | string): DOMWrapper +findComponent(selector: NameSelector | RefSelector): VueWrapper +findComponent(selector: T | FindComponentSelector): VueWrapper +findComponent(selector: FindComponentSelector): WrapperLike ``` **Details:** @@ -1194,12 +1198,29 @@ expect(childByCss.vm.$options.name).toBe('Root') // => still Root The reason for such behavior is that `RootComponent` and `ChildComponent` are sharing same DOM node and only first matching component is included for each unique DOM node ::: +:::info WrapperLike type when using CSS selector +When using `wrapper.findComponent('.foo')` for example then VTU will return the `WrapperLike` type. This is because functional components +would need a `DOMWrapper` otherwise a `VueWrapper`. You can force to return a `VueWrapper` by providing the correct component type: + +```typescript +wrapper.findComponent('.foo') // returns WrapperLike +wrapper.findComponent('.foo') // returns VueWrapper +wrapper.findComponent('.foo') // returns VueWrapper +``` +::: + ### findAllComponents **Signature:** ```ts -findAllComponents(selector: { name: string } | string): VueWrapper[] +findAllComponents(selector: string): WrapperLike[] +findAllComponents(selector: T | Exclude): VueWrapper>[] +findAllComponents(selector: string): DOMWrapper[] +findAllComponents(selector: T): DOMWrapper[] +findAllComponents(selector: NameSelector): VueWrapper[] +findAllComponents(selector: T | FindAllComponentsSelector): VueWrapper[] +findAllComponents(selector: FindAllComponentsSelector): WrapperLike[] ``` **Details:** diff --git a/docs/guide/advanced/component-instance.md b/docs/guide/advanced/component-instance.md index 454a88c67..5bdc70666 100644 --- a/docs/guide/advanced/component-instance.md +++ b/docs/guide/advanced/component-instance.md @@ -72,6 +72,17 @@ A more thorough way to test this would be asserting against the rendered content Note: if you are using a `