vitest-dev / vitest-dev/vitest
In vitest browser mode with WebdriverIO, using `clear` or `fill("")` doesn't trigger the `input` event, as it should
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
I noticed that calling clear on an input won't trigger the input event when using the WebDriver backend.
This is more a FYI in case anybody else finds the issue, but I think ultimately it's up to the browser vendors to fix the issue.
Reproduction
I created a testcase in https://github.com/julienw/testcase-vitest-input-clear.
In that repository you'll find 3 examples of the same app with the same tests:
- With playwright everything happens as I expect: I get the
inputevent. - With @testing-library/user-event I also get the
inputevent. - However with webdriver.io I don't get this event.
Playwright sends the event in https://github.com/microsoft/playwright/blob/3afe7ba8c020e1f69c703dce1801d258bd726f89/packages/injected/src/injectedScript.ts#L838-L839 (called from https://github.com/microsoft/playwright/blob/3afe7ba8c020e1f69c703dce1801d258bd726f89/packages/playwright-core/src/server/dom.ts#L594 )
user-event sends the event in https://github.com/testing-library/user-event/blob/ebab6c6e81e7022af7afa5aacd07d01626895eb8/src/event/input.ts#L176-L179 (called from https://github.com/testing-library/user-event/blob/ebab6c6e81e7022af7afa5aacd07d01626895eb8/src/utility/clear.ts#L22)
But webdriver.io doesn't.
But I think it should according to the webdriver specification: https://w3c.github.io/webdriver/#dfn-clear-algorithm
A workaround is fairly easy:
await searchInput.click(); // Focus the input
await userEvent.keyboard("{Ctrl>}a{/Ctrl}"); // Select all (Cmd or Control+A)
await userEvent.keyboard("{Backspace}"); // Delete
Even though it's 3 lines instead of 1.
I was under the impression that await userEvent.keyboard("{selectall}{Backspace}"); would work too but it doesn't.
System Info
System:
OS: Linux 6.7 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11900H @ 2.50GHz
Memory: 37.07 GB / 62.54 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 24.8.0 - /home/julien/.nvm/versions/node/v24.8.0/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 11.6.0 - /home/julien/.nvm/versions/node/v24.8.0/bin/npm
pnpm: 10.9.0 - /home/julien/.local/share/pnpm/pnpm
bun: 1.0.29 - /home/julien/.bun/bin/bun
Deno: 2.0.0 - /home/julien/.cargo/bin/deno
Watchman: 4.9.0 - /usr/bin/watchman
Browsers:
Chrome: 139.0.7258.127
Chromium: 139.0.7258.127
Firefox: 128.13.0esr
Firefox Developer Edition: 128.13.0esr
npmPackages:
@vitest/browser: ^3.2.4 => 3.2.4
vite: ^7.1.7 => 7.1.9
vitest: ^3.2.4 => 3.2.4
webdriverio: ^9.20.0 => 9.20.0
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked minimal reproduction and compare the Playwright, user-event, and WebdriverIO cases described in the issue. Check the WebDriver clear algorithm and determine whether Vitest can address the behavior or whether it belongs with the browser or WebdriverIO vendors; done means identifying the responsible component and a confirmed path forward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100