Skip to content

Could fireEvent return the event created somehow? #257

@dbismut

Description

@dbismut

Access the event created by fireEvent

I would like to get access the event created by fireEvent. I rely on event.timeStamp to do calculations in my component and testing without access to the created event is complex.

Suggested implementation:

const { canceled, event } = fireEvent[key](node, { ...eventProps })

canceled would be the result of element.dispatchEvent (ie the current return value of fireEvent) and event would be the event created.

Describe alternatives you've considered:

  • Base my calculations on Date.now() in my component
  • Use timeStamp = Date.now() + 1 right before fireEvent (for some reason they equal the timeStamp created by fireEvent
  • [current solution]: create the event manually and fire it with fireEvent(element, event)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds discussionWe need to discuss this to come up with a good solution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions