0
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.

1

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

The link doesn't work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.