Skip to content

Can't set which when triggering keydown event #1162

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
eostrom opened this issue Feb 24, 2019 · 2 comments
Closed

Can't set which when triggering keydown event #1162

eostrom opened this issue Feb 24, 2019 · 2 comments
Labels

Comments

@eostrom
Copy link
Contributor

eostrom commented Feb 24, 2019

Version

1.0.0-beta.29

Reproduction link

https://codesandbox.io/s/8k2z89m41j?fontsize=14

Steps to reproduce

  1. Open CodeSandbox URL.
  2. Open Tests tab.

What is expected?

The tests should pass. (The component and tests are copied from https://vue-test-utils.vuejs.org/guides/#testing-key-mouse-and-other-dom-events.)

What is actually happening?

An error: "Cannot assign to read only property 'which' of object '#'"


I ran into this bug while trying to follow the guide to test keyboard events in my component.

@eostrom
Copy link
Contributor Author

eostrom commented Feb 24, 2019

MDN says which is deprecated and read-only, so maybe the problem is just that the documentation example is not widely supported. Following links, it seems that the appropriate non-deprecated property is key, and this passes for me. I'd be happy to submit a doc PR.

@eddyerburgh
Copy link
Member

A PR to update the docs would be great :)

eostrom added a commit to eostrom/vue-test-utils that referenced this issue Mar 2, 2019
`event.which` is deprecated, `event.key` works.

Closes vuejs#1162.
eostrom added a commit to eostrom/vue-test-utils that referenced this issue Mar 2, 2019
`event.which` is deprecated and (at least in recent Chrome) can't be
set, which made the example test fail. `event.key` works.

Closes vuejs#1162.
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