-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Interactivity API for Browser Mode #5770
Comments
If I am understanding this correctly, till this vitest/browser Instead we would have to interact with components directly with the DOM API's? |
In the latest beta only the click is implemented. There will be a few more APIs from user event before the Vitest 2, but not all of them. How you implement interaction in the meantime is up to you. You can still use Commands API to communicate with playwright/webdriverio, for example. Or you can use userEvent library directly relying on fake events for now. |
v2.0.0-beta.11 should have these API implemented (#5882):
Not all Not implemented APIs (yet): Also it has some non-userEvent APIs:
|
I wasn't sure if it was worth opening a new issue or adding to this one so apologies if this is in the wrong place. V9 of Webdriver IO seems to break some of these API's. |
|
Though, these tests can't run until `userEvent.pointer` is available in Vitest: vitest-dev/vitest#5770
Hi, I'm having hard time figuring out the way how userEvent.keyboard('{ArrowRight}') // OR
userEvent.keyboard('{ArrowLeft}') To mimic the arrow left and right on the keyboard. If I understanding correctly that userEvent.keyboard('[ArrowRight]') // OR
userEvent.keyboard('[ArrowLeft]') but still no luck, instead I had to use : document.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowRight' })) // OR
document.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowLeft' })) to make it work. Is that expected behaviour or am I doing it wrong? for context I'm using |
After messing around I noticed that the following also not working when using await userEvent.tab()
await page.getByTestId('some-el').click() But work using |
Clear and concise description of the problem
There are libraries that allow faking events in
jsdom
/happy-dom
environments (e.g.,@testing-library/user-event
). They are required in Node.js runtime because there is no actual browser, only Web-compatible globals. In Browser Mode, we have access to an actual browser and providers have access to DevTools and Webdriver protocols that could be used to trigger actual events.Suggested solution
The
userEvent
API is very well designed and works great with other@testing-library
packages. Since we already decided to recommend testing-library in browser mode, I think we should provide our ownuserEvent
implementation that uses DevTools or Webdriver protocol depending on the provider.Alternative
No response
Additional context
For the
preview
provider, we can use theuserEvent
library directly.Validations
The text was updated successfully, but these errors were encountered: