Skip to content

Find function does not return DOMWrapper type as declared #1941

Open
@iliubinskii

Description

@iliubinskii

Subject of the issue

The following code:

const wrapper = mount({
  template: '<div class="existent"></div>'
});
console.log(wrapper.find(".existent") instanceof DOMWrapper);
console.log(wrapper.find(".non-existent") instanceof DOMWrapper);

returns "true false".

But according to function declaration:

abstract find(selector: string): DOMWrapper<Element>;

it should return "true true".

The problem is that inside JEST matcher I can't easily check that value is wrapper.

Steps to reproduce

See the first code snippet above.

Expected behaviour

Find function should return DOMWrapper as declared.

OR

It should return "DOMWrapper | NotFoundWrapper" and it should be declared accordingly.

Actual behaviour

Function does not return what is declared.

Possible Solution

  1. Return DomWrapper for non-existent element
  2. Return DOMWrapper | NotFoundWrapper

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions