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

Using find({ref: '...'}) to target an Element logs a deprecation warning #1931

Open
alecgibson opened this issue Nov 23, 2021 · 4 comments
Open
Labels

Comments

@alecgibson
Copy link

Subject of the issue

Trying to find an Element by its ref gives a deprecation warning.

Steps to reproduce

Consider this component:

<template>
  <div>
    <div ref="child" />
  </div>
</template>

If I want to find the "child" element, I'd like to be able to write:

wrapper.find({ref: 'child'})

However, if I do this, then I get a deprecation warning, because my selector isn't a DOM_SELECTOR (it's a REF_SELECTOR).

On the other hand, if I do what the deprecation warning suggests and use findComponent(), then the test fails, because findAllComponents() filters for isVueWrapper, which fails for an Element.

Expected behaviour

I should be able to use find({ref: ''}) to target an Element without a deprecation warning, or use findComponent({ref: ''}), as suggested.

Actual behaviour

I get deprecation errors in my tests.

Possible Solution

The obvious workaround is to not use a ref to target the Element, but it's not ideal, since a ref is a nice, syntactic non-style-based way of targeting an element for testing, which aligns with Vue's own syntax (as opposed to adding eg a data-test attribute or similar).

@alecgibson
Copy link
Author

alecgibson commented Nov 23, 2021

I think this may have been a regression introduced by #1910 ? That is, I think we used to be able to use findComponent({ref: ''} to find an Element (and therefore avoid the deprecation warning), but now can't...?

@tagucch
Copy link

tagucch commented Feb 3, 2022

I'm having the same problem.
In ver 1.2.2, the tests that used to pass with wrapper.findAllComponents({ ref: 'example' }) will now fail.

@ebisbe
Copy link
Collaborator

ebisbe commented Sep 8, 2022

@tagucch For me 1.2.2 is working but 1.3.0 is not.

@ebisbe ebisbe added the bug label Jan 23, 2023
@ebisbe
Copy link
Collaborator

ebisbe commented Feb 8, 2023

I'll have a look at that issue. I had to downgrade to 1.2.2 as well to make the tests pass.

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

No branches or pull requests

3 participants