Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to test emited method from child component vue js

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()
Source by forum.vuejs.org #
 
PREVIOUS NEXT
Tagged: #test #emited #method #child #component #vue #js
ADD COMMENT
Topic
Name
3+4 =