Vue Warn: Component emitted event customEvent but it is neither declared in the emits option...

See original GitHub issue

I saw issue 197, and the apparent fix. But I am getting this warning message still.

My set up is fairly simple:

  1. Parent component is shallow mounted.
  2. Child component is found via wrapper.findComponent.
  3. Child component performs a childComponent.vm.$emit('customEvent')

And, the actual child component does have the custom event in the emits option.

Within the test, I tried setting the global.config.warnMessage’s option to simply return if the message arg included the warning, but that didn’t work. I also tried childComponent.vm.$options.emits = ['customEvent'] but it did not work either.

Any ideas?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
marvin-wttcommented, Aug 31, 2022

This error occurred to me as well. It happened when I changed the emit definition, but the page was only hot updated. After a complete reload, everything was fine. Therefore, it’s not related to this repo IMO, but maybe helpful for someone else getting a similar error.

1reaction
brandonwozcommented, Feb 19, 2021

Factory simply shallowMounts the component.

const factory = (overrides?: MountingOptions<{}>) => {
  const options: MountingOptions<{}> = {};
  return shallowMount(ParentCmp, mergeWith(options, overrides));
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue Warn: Component emitted event customEvent but it is ...
Vue Warn : Component emitted event customEvent but it is neither ... event "continue" but it is neither declared in the emits option...
Read more >
Component emitted event but it is neither ... - Vue Forum
[Vue warn]: Component emitted event "angle" but it is neither declared in the emits option nor as an "onAngle" prop.
Read more >
vuejs 3: declare an emit event in a child component via emits ...
If the listener is intended to be a component custom event listener only, declare it using the "emits" option. I understand the "emits"...
Read more >
component emitted event but it is neither ... - Syncfusion
Hello,. I am using NumericTextBox and DropdownList Component in Vue3. It works fine but I keep seeing warning in the browser console window....
Read more >
A Guide to Vue $emit - How to Emit Custom Events in Vue
Defining your custom events using emits​​ If we're not using defineEmits , we can still keep track custom events for a component by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found