Open alexmccabe opened 2 years ago
I tried digging through the source and as far as I can tell it creates and dispatches the event, so it should work, but the method is never called
Workaround is to call the listener handler directly, but that feels wrong to me: wrapper.vm.onClick({} as MouseEvent)
Subject of the issue
Vue supports dynamic listener names, here's a contrived example of what I mean:
This works in the real world code running in a web browser. However inside vue-test-utils when calling
wrapper.trigger('click')
on the element, the handler is never called. Replacing the template with<MyElement @click.native="onClick" />
works as expected.This isn't due to a timing issue since logging the return value of the computed property elsewhere in the component, dumping to the DOM and using a whole bunch of
await wrapper.vm.nextTick()
in the test yields no result with the dynamic listener name.Steps to reproduce
CustomComponent.vue
TestComponent.vue
TestComponent.test.ts
Expected behaviour
I would expect the tested expectation to pass and there to be a
console.log
Actual behaviour
Changing the template to below yields a test pass
Possible Solution
Since it's not valid to attach
.native
modifiers to non-Vue elements, this doesn't work as intended.