How to mock a global componente?
Source: https://github.com/vuejs/vue-test-utils/issues/894
https://vue-test-utils.vuejs.org/guides/#stubbing-components
https://lmiller1990.github.io/vue-testing-handbook/stubbing-components.html
// Using stubs
import { shallowMount } from '@vue/test-utils'
import LmPagination from '@/components/LmPagination.vue'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
describe('LmPagination', () => {
const wrapper = shallowMount(LmPagination, {
propsData: {
allRegistries: 300,
maxAmountItemsShowsPerPaginationInTable: 10
},
mocks: {
$t: (msg) => msg
},
stubs: {
'font-awesome-icon': FontAwesomeIcon
}
})
test('is a Vue instance', () => {
expect(wrapper.isVueInstance()).toBeTruthy()
})
it('has a li', () => {
expect(wrapper.contains('li')).toBe(true)
})
})