Skip to content
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

Open
4 tasks done
sheremet-va opened this issue May 24, 2024 · 5 comments
Open
4 tasks done

Interactivity API for Browser Mode #5770

sheremet-va opened this issue May 24, 2024 · 5 comments
Labels
feat: browser Issues and PRs related to the browser runner p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@sheremet-va
Copy link
Member

sheremet-va commented May 24, 2024

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 own userEvent implementation that uses DevTools or Webdriver protocol depending on the provider.

Alternative

No response

Additional context

For the preview provider, we can use the userEvent library directly.

Validations

@sheremet-va sheremet-va added feat: browser Issues and PRs related to the browser runner p2-nice-to-have Not breaking anything but nice to have (priority) labels May 24, 2024
@charlieforward9
Copy link

charlieforward9 commented Jun 12, 2024

If I am understanding this correctly, till this vitest/browser userEvent API is finished we cannot interact with our components in browser mode similar to how we do using the testing-library userEvent API??

Instead we would have to interact with components directly with the DOM API's?

@sheremet-va
Copy link
Member Author

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.

@sheremet-va
Copy link
Member Author

sheremet-va commented Jun 18, 2024

v2.0.0-beta.11 should have these API implemented (#5882):

Not all options are supported though.

Not implemented APIs (yet):

Also it has some non-userEvent APIs:

  • userEvent.fill to clear the input and type the value
  • userEvent.dragAndDrop for universal support for drag and drop (not supported in preview)

@luc122c
Copy link

luc122c commented Aug 20, 2024

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.

@sheremet-va
Copy link
Member Author

userEvent.upload is implemented in #6442 and will be available in Vitest 2.1-beta.7

jacomyal added a commit to jacomyal/sigma.js that referenced this issue Oct 29, 2024
Though, these tests can't run until `userEvent.pointer` is available in
Vitest:
vitest-dev/vitest#5770
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: browser Issues and PRs related to the browser runner p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

No branches or pull requests

3 participants