Skip to content

Vitest browser mode userEvent type not recognizing special chars #6871

@Seboran

Description

@Seboran

Describe the bug

When using vitest browser mode, the following test fails:

import { expect, test } from 'vitest'
import { render } from 'vitest-browser-vue'
import HelloWorld from './HelloWorld.vue'
import { userEvent } from '@vitest/browser/context'


test('renders name', async () => {
  const { getByText, getByRole } = render(HelloWorld, {
    props: { name: 'Vitest' },
  })
  await userEvent.type(getByRole('textbox'), "éèù")
})

Fails with Error: keyboard.down: Unknown key: "é"

é is a valid key in AZERTY french keyboards. I cannot use userEvent.fill because I want to test the specific press of special char keys.

With playwright I can type the é key with their equivalent method.

Reproduction

clone https://github.com/Seboran/special-chars-vitest

pnpm i
pnpm test:browser

get error message Error: keyboard.down: Unknown key: "é"

System Info

System:
    OS: macOS 15.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 796.86 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.5.0 - ~/.nvm/versions/node/v20.5.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.5.0/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.5.0/bin/npm
    pnpm: 9.12.1 - ~/Library/pnpm/pnpm
    bun: 1.1.29 - ~/.bun/bin/bun
  Browsers:
    Safari: 18.1
  npmPackages:
    @vitejs/plugin-vue: ^5.1.4 => 5.1.4 
    @vitest/browser: ^2.1.4 => 2.1.4 
    @vitest/eslint-plugin: 1.1.7 => 1.1.7 
    vite: ^5.4.10 => 5.4.10 
    vitest: ^2.1.4 => 2.1.4

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runnerp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions