I have a Vue functional component, with some tests using Jest, but the coverage say 0 for this file. Is this the right way to test functional components in Vue?
this is an example of my component
<template functional>
<div :class="['name', ...props.extraClasses]">
{{ props.itemName }}
</div>
</template>
<script>
export default {
props: {
itemName: {
type: String,
required: true,
},
extraClasses: {
type: Array,
},
},
};
</script>
This is what 1 of my tests look like
test('it works correctly with all props', () => {
const wrapper = shallow(cmp, {
context: {
props: {
itemName: 'item name',
extraClasses: ['extra1', 'extra2'],
}
},
})
const name = wrapper.find('.name');
expect(name.classes()).toEqual(['name', 'extra1', 'extra2']);
expect(name.text()).toBe('item name');
});
After I run jest, I'm seeing the coverage is 0, and the uncovered lines are the props. Is there any other way to test the functional component?
And how do I get the jest coverage to work correctly for this test file?
Thank you