Reputation: 117
Do you know what's the correct way to test functions that are declared inside the reactive variables in VUE. To achieve 100% coverage in the component, Jest says is needed to apply test to this functions.
Example: The function customData is inside the reactive var chartOptions and must be tested:
export default{
name: 'component',
data: function () {
chartOptions: {
customData: function ({ val1 }) {
return val1 > 0 ? val1 * 2 : 0
}
}
}
}
I appreciate your help
Upvotes: 0
Views: 408
Reputation: 194
Once you mount your computed in jest, you can access the function through
wrapper.vm.charOptions.customData
Then call the function as you would normally do and test its output. For branch output you probably need to call it twice
Upvotes: 1