Running jest with bootstrap-vue
If you're adding bootstrap vue as a global plugin:
Vue.use(BootstrapVue);
Then in your tests, you're likely going to want to follow this tip:
https://vue-test-utils.vuejs.org/guides/common-tips.html#applying-global-plugins-and-mixins
Which outlines how you can use the createLocalVue()
and set it up with the same global config as your app:
import { createLocalVue } from '@vue/test-utils'
// create an extended `Vue` constructor
const localVue = createLocalVue()
// install plugins as normal
localVue.use(BootstrapVue)
// pass the `localVue` to the mount options
mount(Component, {
localVue
})
Then your components should be registered properly-
It is also possible to stub components like
const wrapper = mount(Login, {
mocks: {
$t: () => 'Connexion' // i18N
},
stubs: {
BCol: true
}
});