It's pretty clear on how to test for the existence of a child component using Vue Test Utils through the official docs.
However, it's unclear how to test for the existence of a HTML element within that child element.
Say I have the following Child component.
<template>
<div>Child<span>Random</span></div>
</template>
<script>
export default {
name: "Child"
}
</script>
And I have the following Parent component.
<template>
<div>
<span v-show="showSpan">
Parent Component
</span>
<Child v-if="showChild" />
</div>
</template>
<script>
import Child from "./Child.vue"
export default {
name: "Parent",
components: { Child },
data() {
return {
showSpan: false,
showChild: false
}
}
}
</script>
The following snippet would be how I would find the existence of the child component.
it("renders a Child component", () => {
const wrapper = shallowMount(Parent, {
data() {
return { showChild: true }
}
})
expect(wrapper.find({ name: "Child" }).exists()).toBe(true)
})
However, my question is, how would I assert the existence of <span>Random</span>
if I wanted to?