Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Testing handlers should not require that you add parentheses #530

Copy link
Copy link
Open
@lobo-tuerto

Description

@lobo-tuerto
Issue body actions

Subject of the issue

Right now if you have a child component that handles an emitted event by calling a function in the parent component, it will just fail if you don't add parenthesis to the event handler name.

Steps to reproduce

This works:

<MainTopbar @account="handleTopbarAccountClick()" />

This does not work:

<MainTopbar @account="handleTopbarAccountClick" />

Expected behaviour

This should work:

<MainTopbar @account="handleTopbarAccountClick" />

Actual behaviour

This just fails and I think there isn't enough information as to why if the Vue documentation exemplifies event handling usually without parentheses.

<MainTopbar @account="handleTopbarAccountClick" />

Possible Solution

For now, use parenthesis on all event handlers.
Talk to the Vue team about it, make them change their ways/docs :P
Add this information in a very visible place on the Vue Test Utils docs.

Previous discussions

vuejs/vue-test-utils#1901
vuejs/vue-test-utils#929
https://stackoverflow.com/questions/62696939/test-on-function-call-in-vue-template-only-passes-if-the-function-is-called-with/62703070#62703070

el-j

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.