Open riophae opened 7 years ago
I think this is a great suggestion. Are you able to implement it? We could release, along with your other changes, in 4.0.0
Yeah, no problem!
I think we could outsource the work to this module https://github.com/KenanY/create-event ?
Yes, although we can only use it for keyup, keydown click and dblclick events
On Thu, Aug 10, 2017 at 8:24 PM, Fangzhou Li notifications@github.com wrote:
I think we could outsource the work to this module https://github.com/KenanY/create-event ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/eddyerburgh/avoriaz/issues/102#issuecomment-321649159, or mute the thread https://github.com/notifications/unsubscribe-auth/AMlbW0LzB2CCtAtQi-GEyjv49mvClYYPks5sW1jzgaJpZM4OxUvN .
These days I have spent some time reading the source code of triggerhappy. It provides a lots more features, including touch events testing. I think we can learn something from it and jest and we will have a lot to discuss about. But for now, I think there is an urgent need for testing keyboard events and we should implement that as soon as possible. I'll outsource the work to create-event for the time being.
I don't know if anyone is already working on this issue/enhancement, but can that person also look at the feature of key + shiftKey=true (and altKey) because that is currently also not functioning. in specific this line wrapper.find('input')[0].trigger('keyup', { keycode: 53, shiftKey: true });
(in this case %)
@mathijswesterhof Hi, I'm not working on this. Sorry.
This project isn't actively maintained, although I'm happy to accept PRs.
I recommend using Vue Test Utils, which is based on avoriaz—https://github.com/vuejs/vue-test-utils
good to know, i'll try to migrate then, see if the problem is solvable on vue-test-utils. if not I'll make a pr there
Though it's possible to simulate some specific keys to test keyboard events, it's actually too limited - only a few keys are allowed:
https://github.com/eddyerburgh/avoriaz/blob/c6fa79e30cf774493cc832ebf8edfc8f30a2b07f/src/Wrapper.js#L373-L383
So I think it's necessary to make it possible to test any keys.
Also, as this article suggests, it's best to watch
event.which
property rather thanevent.keyCode
. But avoriaz has only set value forkeyCode
property. If onlyevent.which
has been used by the application logic, then we can not test that at all.https://github.com/eddyerburgh/avoriaz/blob/c6fa79e30cf774493cc832ebf8edfc8f30a2b07f/src/Wrapper.js#L397-L400
In general, the synthetic event should be able to be freely modified to suit any specific needs: