【发布时间】:2020-05-14 18:26:53
【问题描述】:
我正在使用带有 Jest 的 Nuxt.js 进行单元测试。我在布局中添加了一个 head 函数来更改标题,我想对其进行单元测试。 这是我的文件:
<template>
<h1 class="title">HELLO</h1>
</template>
<script>
export default {
data () {
return {
title: 'MY TITLE'
}
},
head () {
return {
title: this.title,
meta: [
{ hid: 'description', name: 'description', content: 'MY DESCRIPTION' }
]
}
}
}
</script>
我试过了:
const wrapper = shallowMount(index)
wrapper.vm.head() <- fails
有什么建议吗?
【问题讨论】:
标签: unit-testing vue.js jestjs nuxt.js