I have a test suite in vitest that is passing, but it is showing the relevant code in the coverage report to be uncovered. Vitest is v1.4.0 and the coverage provider is @vitest/coverage-istanbul v1.4.0.
Here is my test suite:
describe('My Page', () => {
let store
let wrapper
beforeEach(() => {
const pinia = createPinia()
setActivePinia(pinia)
store = useMyStore()
wrapper = shallowMount(MyComponent)
})
test('date is being set to state', async () => {
const testDate = new Date()
store.info.ymd = testDate
await wrapper.vm.$nextTick()
expect(wrapper.vm.info.ymd).toBeInstanceOf(Date)
expect(wrapper.vm.info.ymd).toEqual(testDate)
})
})
And in my component, the statement inside the computed property () => new Date(store.info.ymd) is showing to be uncovered.
<script setup>
const store = useMyStore()
const ymd = computed(() => new Date(store.info.ymd))
</script>
<template>
<date-component v-model="ymd" />
</template>
I am expecting the above vue code to be covered in the report, but it is not.