Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Last active June 13, 2019 17:42
Show Gist options
  • Save AlbinoDrought/1a15955ddfe71c6b3df6a9ef8c4a07a7 to your computer and use it in GitHub Desktop.
Save AlbinoDrought/1a15955ddfe71c6b3df6a9ef8c4a07a7 to your computer and use it in GitHub Desktop.
@vue/test-utils error with vue-property-decorator, vue-class-component: "Property 'functional' is missing in type 'VueConstructor" [saved for later]

@vue/test-utils cryptic error

Encountered this and I know I'll end up making the same mistake again. Saving it here so I can hopefully find it on Bing ™️ in the future.

Error

Argument of type 'VueConstructor<Vue>' is not assignable to parameter of type 'FunctionalComponentOptions<Record<string, any>, PropsDefinition<Record<string, any>>>'.
  Property 'functional' is missing in type 'VueConstructor<Vue>' but required in type 'FunctionalComponentOptions<Record<string, any>, PropsDefinition<Record<string, any>>>'.

Sample Test

import { Wrapper, config, mount } from '@vue/test-utils';

import Form from '@/components/Form.vue';

describe('Form.vue', () => {
  it('should look fantastic', () => {
    const wrapper = mount(Form, { // <-- big red squiggly here preventing you from moving further
      props: {
        title: 'I am a talking computer',
      },
    });
  });
});

The Fix

When using @vue/test-utils, props are passed to components using propsData, not props. Using props causes the above cryptic error message.

import { Wrapper, config, mount } from '@vue/test-utils';

import Form from '@/components/Form.vue';

describe('Form.vue', () => {
  it('should look fantastic', () => {
    const wrapper = mount(Form, {
      propsData: { // <-- `propsData` instead of `props`
        title: 'I am a talking computer',
      },
    });
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment