I'm trying to set up an end-to-end test using Cypress. I can already render a Mathfield and simulate some user input to it by triggering clicks on virtual keyboard buttons.
What I'd like to do now is simulate user keypresses. Taking Cypress out of the equation for a moment, here's my non-working code executed in the browser console.
let elt = $('math-field'); // ok
elt.focus(); // ok, document.activeElement changed
document.dispatchEvent(new KeyboardEvent('keydown', { key:'e', keyCode: 69 }));
document.dispatchEvent(new KeyboardEvent('keyup', { key:'e', keyCode: 69 })); // nada
Am I sending wrong events or targeting the wrong element? Is this possible to do, or should I just use the elt.setValue() method, even if my users won't use that?
I'm trying to set up an end-to-end test using Cypress. I can already render a Mathfield and simulate some user input to it by triggering clicks on virtual keyboard buttons.
What I'd like to do now is simulate user keypresses. Taking Cypress out of the equation for a moment, here's my non-working code executed in the browser console.
Am I sending wrong events or targeting the wrong element? Is this possible to do, or should I just use the
elt.setValue()method, even if my users won't use that?