jest 不会收集 vue 文件的覆盖范围,以防它在脚本中只有 DefineProps 和 DefineEmit
我不确定为什么 Jest 覆盖行为在下面的场景中发生变化,
如果我有如下代码,它不会收集覆盖范围。
<template>
<Teleport to="body">
<div v-if="show" class="modal">
<div class="modal_content">
<div class="message xxl">
<slot></slot>
</div>
<button class="button button--info" @click="$emit('reset')">
continue
</button>
</div>
</div>
</Teleport>
</template>
<script setup>
defineProps({
show: Boolean,
});
defineEmits(["reset"]);
</script>
但如果我只是添加一个虚拟控制台语句,它就可以
<template>
<Teleport to="body">
<div v-if="show" class="modal">
<div class="modal_content">
<div class="message xxl">
<slot></slot>
</div>
<button class="button button--info" @click="$emit('reset')">
continue
</button>
</div>
</div>
</Teleport>
</template>
<script setup>
defineProps({
show: Boolean,
});
console.log("--silent");
defineEmits(["reset"]);
</script>
对于为什么会发生这样的情况有什么想法吗?
i am not sure why Jest coverage behavior changes in below scenario
it does not collect a coverage if i have code like below.
<template>
<Teleport to="body">
<div v-if="show" class="modal">
<div class="modal_content">
<div class="message xxl">
<slot></slot>
</div>
<button class="button button--info" @click="$emit('reset')">
continue
</button>
</div>
</div>
</Teleport>
</template>
<script setup>
defineProps({
show: Boolean,
});
defineEmits(["reset"]);
</script>
but if i just add a dummy console statement it works
<template>
<Teleport to="body">
<div v-if="show" class="modal">
<div class="modal_content">
<div class="message xxl">
<slot></slot>
</div>
<button class="button button--info" @click="$emit('reset')">
continue
</button>
</div>
</div>
</Teleport>
</template>
<script setup>
defineProps({
show: Boolean,
});
console.log("--silent");
defineEmits(["reset"]);
</script>
any thoughts on why it is happening like this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论