Vue.js 如何调用从props传入的函数

Vue.js 如何调用从props传入的函数,vue.js,jestjs,Vue.js,Jestjs,我有一个函数作为测试中的道具传入。我需要调用该函数并对其进行测试。我如何引用它?下面是一些示例代码 const testFucntion() { return "doesn't matter what this does" } describe('test', () => { beforeEach(() => { wrapper = shallowMount(SelectEquipment, { ...jestVueStack, pro

我有一个函数作为测试中的道具传入。我需要调用该函数并对其进行测试。我如何引用它?下面是一些示例代码

const testFucntion() {
   return "doesn't matter what this does"
}

describe('test', () => {
beforeEach(() => {
    wrapper = shallowMount(SelectEquipment, {
        ...jestVueStack,
        propsData: {
            onSelect: testFunction
        }
    })
})

it('does the thing it's supposed to do. ', () => {
    wrapper.propsData.onSelect()
    expect(wrapper.onSelect).toHaveBeenCalled()
  })

})

不知道如何实际调用
propsData.onSelect
我在那里的方式不起作用

这完全取决于您使用什么库从中获取
shallowMount
“不起作用”的确切含义是什么?该函数不是间谍,因此无法使用ToHaveBeenCall对其进行测试。目的也不清楚,目前您正在测试您自己的代码。