📜  如何从子组件 vue js 测试发出的方法 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:14.048000             🧑  作者: Mango

代码示例2
const stub = sinon.stub()
const wrapper = mount(ParentComponent)
 // just a simple assertion that your parent component's handler for input event was called
wrapper.setMethods({ methodToTest: sub })

// you can pass a component in `find()` method then trigger the component's event
wrapper.find(ChildComponent).trigger('input')

// assert if the listener was called
expect(stub.called).tobeTruthy()