📜  vue 单元测试表单提交 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:22.895000             🧑  作者: Mango

代码示例1
const div = document.createElement('div')
div.id = 'root'
document.body.appendChild(div)

it('button click triggers submit event', () => {
  const wrapper = shallowMount(Form, {
    attachTo: '#root'
  })

  wrapper.find("[type='submit']").trigger('click')

  assert.exists(
    wrapper.emitted('submitEventTriggered'),
    'Form submit not triggered'
  )
})