1.0.0-beta.15
I have a component with item prop:
<template>
<h2>{{ item.name }}</h2>
</template>
<script>
export default {
name: 'CaseCard',
props: {
item: {
type: Object,
required: true
}
}
}
</script>
My prop item should be required, my test:
import { mount } from '@vue/test-utils'
import CaseCard from './CaseCard'
const cardsData = [
{ name: 'A', image: 'A', route: 'A', tags: ['A', 'AA']}
]
describe('CaseCard component', () => {
test('render case name in h2 tag', () => {
const component = mount(CaseCard, {
propsData: {
item: cardsData[0]
}
})
const h2Tag = component.find('h2')
expect(h2Tag.text()).toBe(cardsData[0].name)
})
})
I think that it works and my test pass, but no works.
The error returned is: [Vue warn]: Missing required prop: "item"
If I remove required from my prop, the test pass, but I need use required.
Sorry, the mistake was mine, I had not realized.
I get the same error. Any idea what fixed it?
your code has some error, in the same component or in parent or child components of it.