Hey guys,
I have the next test-case:
import ParentComponent from './ParentComponent'
import ChildComponent from './ChildComponent'
it('does not render <ChildComponent>', () => {
const wrapper = shallow(ParentComponent)
expect(wrapper.contains(ChildComponent)).toBe(false)
})
ParentComponent:
<template>
<div>
<AnotherComponent />
<ChildComponent />
</div>
</template>
<script></script>
However the test fails.
After debugging I found out selector.name is undefined:
https://github.com/vuejs/vue-test-utils/blob/dev/src/wrappers/wrapper.js#L78
unless I explicitly declare ChildComponent as this (which makes my test to pass):
<template>...</template>
<script>
export default {
name: 'ChildComponent'
}
</script>
otherwise selector.name is always undefined.
Printscreen

Any thought will be well appreciated,
Cheers.
Note: shallow and mount behave the same
nvm I just confirmed that's expected
https://vue-test-utils.vuejs.org/en/api/selectors.html
thanks anyway
It's worth noting that contains has been updated to include the wrapper element. So in beta.9 it will behave as you originally expected 馃榾
Most helpful comment
It's worth noting that
containshas been updated to include the wrapper element. So in beta.9 it will behave as you originally expected 馃榾