Adi
Adi

Reputation: 127

Vue test-utils: Trigger right-click event on the Wrapper

import { mount } from '@vue/test-utils'
import sinon from 'sinon'
import Foo from './Foo'

const clickHandler = sinon.stub()
const wrapper = mount(Foo, {
 propsData: { clickHandler }
})

//click works
wrapper.trigger('click')

// right click **doesn't** work
wrapper.trigger('click.right')

// contextmenu **doesn't** work either
wrapper.trigger('contextmenu')

expect(clickHandler.called).toBe(true)

In the above code i was able to trigger mouse click but not able to trigger mouse right-click. I have attempted to trigger the required with 'click.right' and 'contextmenu' without any luck.

any ideas on how to trigger right click. There is no reference of this in the official documentation.

Upvotes: 0

Views: 1886

Answers (1)

Adi
Adi

Reputation: 127

Indeed...wrapper.trigger('contextmenu') works. There was a problem with my code I assumed right click was not getting triggered

@ittus thanks for the link https://github.com/ittus/VueJS-Training/blob/master/vue-test-utils/test.js

Hope this helps someone as triggering right click is not found in official docs

Upvotes: 1

Related Questions