Last active
February 5, 2019 17:36
-
-
Save pablocattaneo/3cc81f8c67840c1617c521c2b7385a18 to your computer and use it in GitHub Desktop.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment