Skip to content

Trigger click does not recognize shiftKey property #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
loeffel-io opened this issue Mar 28, 2018 · 2 comments
Closed

Trigger click does not recognize shiftKey property #494

loeffel-io opened this issue Mar 28, 2018 · 2 comments
Labels

Comments

@loeffel-io
Copy link

loeffel-io commented Mar 28, 2018

Version

1.0.0-beta.13

Steps to reproduce

This worked pretty fine with an older version. It's not working anymore after the update:

  1. in the application i click on an item with shift key pressed.
  2. in my test i want to reproduce this by this function:
function clickOnFile(index, shiftKey = false) {
    wrapper.findAll('.item....').at(index).trigger('click', {
      shiftKey,
    })
  }
  1. I run this function by clickOnFile(1, true). So now it should click on the item with shift key pressed, but shiftKey is not set at the MouseEvent.

there are also some similar issues: #484

What is expected?

The mouseEvent with shiftKey: true.

What is actually happening?

The mouseEvent with shiftKey: false


Thanks

@loeffel-io
Copy link
Author

Is there any update?

@eddyerburgh
Copy link
Member

This works as expected in Jest—https://codesandbox.io/s/8n31yv3nx9. It could be a problem with your environment.

Under the hood, Vue Test Utils creates an Event object with the supplied type, and adds properties from the options to the Event object. From reading the specs, it looks like shiftKey is only specified on a MouseEvent object, where shiftKey is a read-only property. It looks like it's behavior on a standard event object is unspecified, so it could be the environment you're running the tests in does not allow use to set the shiftKey property.

Hopefully this info can give you some insight why event options aren't always applied. I'm closing this issue, since it's environment related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants