I have Component.vue that i need to test:
Component.vue
<script setup>
const someFunction = () => {
//...some code i do not want to execute
}
const functionTotest = () => {
if(someCondition) {
someFunction()
}
}
</script>
The purpose of my test (Jest + vue test utils) is to check if functionToTest works ok - does it actually call someFunction if someCondition === true.
I tried mocking someFunction:
const wrapper = mount(Component, {
global: {
mocks: {
someFunction: jest.fn()
}
}
})
but then when i call wrapper.vm.functionToTest() it still calls original someFunction() from Component.vue and not the mocked one that I provided in global.mocks.
How can i deal with this problem without refactoring Component.vue?