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

userEvent.keyboard('{space}') does not work #972

Closed
nkgrnkgr opened this issue Jun 14, 2022 · 2 comments
Closed

userEvent.keyboard('{space}') does not work #972

nkgrnkgr opened this issue Jun 14, 2022 · 2 comments

Comments

@nkgrnkgr
Copy link

Reproduction example

https://codesandbox.io/s/quiet-butterfly-dcz8ld

Prerequisites

  1. Render <button>button</button> and <div role='dialog'>dialog</div> .
  2. Write test.
  render(<App />);

  const button = await screen.findByRole("button");
  button.focus();

  await userEvent.keyboard("{space}");

  const dialog = await screen.findByRole("dialog");

  expect(dialog).toBeInTheDocument();

Expected behavior

SpaceKey work, and can find a dialog element.

Actual behavior

SpaceKey does not work, and can not find a dialog element.

User-event version

14.2.0

Environment

"dependencies": {
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^14.2.0",
    "@types/jest": "^27.5.2",
    "@types/node": "^16.11.39",
    "@types/react": "^18.0.12",
    "@types/react-dom": "^18.0.5",
    "react": "^18.1.0",
    "react-dom": "^18.1.0",
    "react-scripts": "5.0.1",
    "typescript": "^4.7.3"
  },

Additional context

Enter key and Click button work!😄
But space key does not work🤔

@nkgrnkgr nkgrnkgr added bug Something isn't working needs assessment This needs to be looked at by a team member labels Jun 14, 2022
@ph-fritsche ph-fritsche removed bug Something isn't working needs assessment This needs to be looked at by a team member labels Jun 14, 2022
@ph-fritsche
Copy link
Member

See https://testing-library.com/docs/user-event/keyboard

You can describe the key

  • per printable character: .keyboard(' ')
  • per KeyboardEvent.key: .keyboard('{ }')
  • per KeyboardEvent.code: .keyboard('[Space]')

@ph-fritsche ph-fritsche closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2022
@nkgrnkgr
Copy link
Author

@ph-fritsche

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants