Answer the question
In order to leave comments, you need to log in
Why does jest testing of a vue component fail?
Hello, I have a component with a method:
scrollToParent() {
const id = _get(this, 'comment.attributes.parent_id'); // lodash get
const parentId = `#comment-${id}`;
this.$emit('scrollToParent', parentId, id);
},
<Tag ... @scrollToParent="scrollToParent" ... />
it('scrollToParent - Должен вызвать emit со свойством scrollToParent и payload', () => {
component.vm.$emit = jest.fn();
component.setProps({
comment: {
attributes: {
parent_id: 3,
},
},
});
component.vm.scrollToParent();
expect(component.vm.$emit).toBeCalledWith('scrollToParent', '#comment-3', 3);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question