Skip to content

Change emitted().someEvent to emitted('someEvent') #157

Closed
@lmiller1990

Description

@lmiller1990

Hi,

Sorry for a lot of issues lately. vue test utils is getting heavy use in my project (that's good!).

I often have tests that check if an event was emitted with the correct arguments. For example, I click a button, and it emits some updated text. In that case, at the moment I do

wrapper.find('#caption-input').element.value = 'New caption')
wrapper.find('#caption-button').trigger('input')
expect(wrapper.emitted().captionChanged[0][0]).toBe('New caption')

Especially the [0][0] is a awkward to type and know what is going on.

What I would like to be able to do:

expect(wrapper.emitted('customEvent').toBeTruthy()

// and something like this for checking the emitted payload, not sure if payload is the right word here though
expect(wrapper.emitted('customEvent').payload.toEqual('newCaption')

If accepted I will make the PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions