vitest-dev / vitest-dev/vitest

In vitest browser mode with WebdriverIO, using `clear` or `fill("")` doesn't trigger the `input` event, as it should

Open
#8,712 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat: browser p3-minor-bug webdriverio
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:

  1. With playwright everything happens as I expect: I get the input event.
  2. With @testing-library/user-event I also get the input event.
  3. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.