Open JealousGx opened 1 year ago
Hello,
I also have issues with userEvent.keyboard
after migrating @storybook/testing-library from 0.1.0 to 0.2.2.
After rollbacking this package to 0.1.0 it's working properly (and no regression with other storybook 7.4 packages).
0.2.X versions are using @testing-library/user-event v14 which bring breaking changes on keyboard events.
More information here:
https://github.com/testing-library/user-event/issues/946
Root cause: https://github.com/testing-library/user-event/issues/842#issuecomment-1019528148
They removed "non-standard" or "deprecated" code but it's now impossible for example to do a simple userEvent.keyboard("[Enter]")
on a focused element.
According to me it's better to use native standard Javascript instead of those kind of librairies. To trigger an enter key we can do instead:
const event = new KeyboardEvent("keydown", { key: "Enter" });
myElement.dispatchEvent(event);
Describe the bug I am facing an issue with the
keyboard
ortype
methods ofuserEvent
.I have this piece of code that plays the story. And I have also modified the functionalities for
backspace
to something else. Basically, aspan
is created upon pressingenter
and whenbackspace
is pressed, the wholespan
is removed and this functionality is achieved through javascript and I am also injecting that javascript code into the story as well. It's working fine with locally run webpack with human interaction, but when it's tested on storybook with testing-library, it doesn't seem to be doing its functionality. In fact,{backspace}
doesn't remove any character at all.FYI: I am using Storybook v7.4.3 and @storybook/testing-library v^0.2.1
This functionality was working fine with storybook v6.5.x but after migrating to v7.4.2, it stopped working.
To Reproduce Steps to reproduce the behavior:
Expected behavior Expected
@storybook/testing-library
to work fine even after updating the storybook version to 7.4.3Screenshots If applicable, add screenshots to help explain your problem.
System Please paste the results of
npx storybook@latest info
here. Environment Info:Additional context Add any other context about the problem here.