vuejs/vue-test-utils

Find should return root node if it's a match

Open

#1,464 创建于 2020年3月11日

在 GitHub 查看
 (8 评论) (1 反应) (0 负责人)JavaScript (657 fork)auto 404
good first issue

仓库指标

Star
 (3,543 star)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南