Skip to content

How to test events being fired #178

Closed
testing-library/testing-library-docs
#1366
@marekdedic

Description

@marekdedic

Hi, I'm trying to create a unit test (which testing-library should be able to help me with, as per its FAQ) for a Component which essentially is just a button. However, I found no way to test that an event is fired when I click the button. I've seen #53 which is probably very similar, so to add to this

  • The button doesn't really change on click (I know how to test for that, for example for a "press" animation)
  • The event being fired is the primary function of the button - so that's what I'd like to test (to check that clicking an icon triggers it as well and so on)

I've tried passing the function in the second argument of render, however, it doesn't seem to be called.

Thanks!

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