【发布时间】:2020-07-15 19:41:36
【问题描述】:
我正在做一些测试,我想检查在我触发元素点击后是否调用了某个方法,但测试一直说没有调用,我不知道为什么
这是我的测试:
test('some test', () => {
const somethingChanged= jest.spyOn(Component.methods, 'somethingChanged')
const wrapper = mount(Component, {
propsData: data
})
const element= wrapper.find('.c-element').trigger('click')
expect(somethingChanged).toBeCalled()
})
这一直说调用次数为0,不知道自己做错了什么 这个方法是在组件中触发的,所以我知道它有效
【问题讨论】:
标签: unit-testing vue.js jestjs