user8555937
user8555937

Reputation: 2387

Vue Test Utils with Jest - Mixins not working

I have created a local Vue app and I need to mix a method into all components. The problem is whenever I mount the app the method does not appear to be mixed for child components. Here is my code:

import { createLocalVue, mount } from '@vue/test-utils'
import {gc} from '.....';
import .... from ....

const App = createLocalVue()

App.use( .... )

App.mixin({
  methods: {
    gc: key => gc(key)
  }
})

export const Wrapper = mount(AppComponent, {
  App,
  i18n,
  router,
  store,
  ...
})

Whenever I import "Wrapper" into any test it fails to the first mounted component with message:

TypeError: _vm.gc is not a function

How can I include mixins to propagate to all the child components?

Upvotes: 0

Views: 793

Answers (1)

Estus Flask
Estus Flask

Reputation: 222369

mount has no App option. Instead, there's localVue to supply Vue copy.

It should be:

 mount(AppComponent, {
  localVue: App,
  ...

Upvotes: 1

Related Questions