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

Bug: wrapper.findComponent no longer working after upgrading to 2.4.2 #2343

Closed
SimonHawesome opened this issue Feb 15, 2024 · 6 comments
Closed
Labels
bug Something isn't working needs reproduction

Comments

@SimonHawesome
Copy link

Describe the bug

Ever since we updated to v2.4.2, we've been experiencing an error with wrapper.find and wrapper.findComponent.

Error: Cannot call vm on an empty VueWrapper.

The find and findComponent methods no longer return a VueWrapper.

To Reproduce

// .vue file
<component data-attribute-handle @close="handleClose"></component>

// test file
wrapper.findComponent('[data-attribute-handle]').vm.$emit('close')

Expected behavior

We are expecting the component to be returned so we can call methods on the component's vm.

wrapper.findComponent('[data-attribute-handle]').vm.$emit('close')
or
wrapper.findComponent('[data-attribute-handle]').vm.selected

Related information:

Vue test utils v2.4.2
Vue 3.2.37

Additional context

@SimonHawesome SimonHawesome added the bug Something isn't working label Feb 15, 2024
@SimonHawesome SimonHawesome changed the title Bug: Bug: wrapper.findComponent no longer working after upgrading to 2.4.2 Feb 15, 2024
@cexbrayat
Copy link
Member

Hi @SimonHawesome

Have you tried with the latest version of Vue (v3.4.15) and VTU (v2.4.4) as well?

If it doesn't work, can you provide us a small repro online using https://stackblitz.com/github/vuejs/create-vue-templates/tree/main/typescript-vitest?file=src%2Fcomponents%2F__tests__%2FHelloWorld.spec.ts ?

It only takes a few minutes, and we'll be able to take a look

@cexbrayat
Copy link
Member

Hi @SimonHawesome

Did you manage to build a repro or did you fix your issue and we can close this?

@SimonHawesome
Copy link
Author

Sorry haven't be able yet, perhaps this week!

@chrismooreajbell
Copy link

Hi are you using vitest? If so you may need to add

    server: {
      deps: {
        inline: ['@vue/test-utils'],
      },
    },

to your vitest config.

@cexbrayat
Copy link
Member

Hi @SimonHawesome

Let me know if you have a repro or if we can close the issue (we can't look into it otherwise). I suspect that using both the later versions of VTU and Vue should be enough to solve it, but I'll wait for your answer before closing.

@cexbrayat
Copy link
Member

Let's close the issue as we had no repro from the OP author.

@cexbrayat cexbrayat closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction
Projects
None yet
Development

No branches or pull requests

3 participants