vuejs/vue-test-utils

Find should return root node if it's a match

Open

#1,464 opened on Mar 11, 2020

View on GitHub
 (8 comments) (1 reaction) (0 assignees)JavaScript (657 forks)auto 404
good first issue

Repository metrics

Stars
 (3,543 stars)
PR merge metrics
 (PR metrics pending)

Description

Version

1.0.0-beta.32

Reproduction link

https://codesandbox.io/s/clever-bush-v4p5i

Steps to reproduce

  1. Create a child component which should emit an event
  2. Create a wrapper component which will render directly only the child component
  3. Set a listener for this created event on the wrapper

Then go to the tests

  1. Use shallowMount to create the wrapper
  2. Stub the event handler function using wrapper.setMethods
  3. Find and emit the event wrapper.find('Child-stub').vm.$emit('your-event')
  4. Assert if event handler function have been called

What is expected?

It's expected the handler function be called

What is actually happening?

It looks when we create a Wrapper component which renders directly a Child component, and then, when the child component emits an event, the wrapper won't call the handle function


On the reproduction link, there are two Wrappers

  • Wrapper doesn't work
  • Wrapper2 works, because I moved my ChildComponent to an <div>

Maybe this can be related with https://github.com/vuejs/vue-test-utils/issues/650#issuecomment-597197194

Contributor guide