Skip to content

wrapper.vm.hasFocus returns opposite value starting in v1.1.3 #1846

Closed
@pechitook

Description

@pechitook

Subject of the issue

We have a very simple test that makes the following assertion

it('Shows options when component is focused', async () => {
    const input = wrapper.find('input');
    await input.trigger('focus');

    expect(wrapper.vm.hasFocus).toBe(true);
});

With @vue/test-utils@1.1.2 this assertion pass. Starting from 1.1.3 and all the way to 1.2.0 (I tested all releases in between) the wrapper.vm.hasFocus assertion returns false.

Steps to reproduce

Shallow mount a component that has an input, then try to focus it:

it('Shows options when component is focused', async () => {
    const input = wrapper.find('input');
    await input.trigger('focus');

    expect(wrapper.vm.hasFocus).toBe(true);
});

Expected behaviour

What should happen?
hasFocus should return a consistent result from v1.1.2 to v1.1.3

Actual behaviour

What happens instead?
hasFocus now returns the opposite value without the test changing

Possible Solution

None of the changes in the release note ring a bell to me about why this may occur :(

What are the alternative solutions? Please describe what else you have considered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions