Skip to content

fireEvent.keyPress does not trigger a focused button #376

Closed
@andraz

Description

@andraz
  • react-testing-library version: 7.0.1
  • react version: 16.8.6

Relevant code or config:

    fireEvent.keyPress(button, { key: 'Enter', code: 13, charCode: 13 })

What you did:

Used info from #269 how to trigger keyPress in test.

What happened:

Did not trigger keyPress in test.

Reproduction:

https://codesandbox.io/s/reacttestinglibrary-testing-button-8bfqb

Problem description:

Button works as expected when you manually press the enter key on it.

Test does not simulate button press when fireEvent.keyPress triggers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions