Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pechitook opened this issue May 10, 2021 · 3 comments
Closed

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

pechitook opened this issue May 10, 2021 · 3 comments

Comments

@pechitook
Copy link

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?

@lmiller1990
Copy link
Member

This same up recently, please see this #1848 and this #1777 (comment).

@lmiller1990
Copy link
Member

Did the above links fix your problem?

@pechitook
Copy link
Author

Adding attachTo: document.body effectively fixed this. Thank you!! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants