feat: 解决vue组件单元测试复杂的环境依赖,以及提交NetworkOverviewLine单元测试用例

This commit is contained in:
chenjinsong
2023-01-10 10:09:13 +08:00
parent 9f488adcb9
commit 431821154e
8 changed files with 340 additions and 217 deletions

View File

@@ -1,21 +1,29 @@
<template>
<span data-test="count">{{count}}</span>
<button data-test="button" @click="click">click</button>
<span test-id="count">{{count}}</span>
<span test-id="title">{{getData.title}}</span>
<button test-id="button" @click="click">click</button>
</template>
<script>
/* vue-jest的测试示例 */
import VueRouter from 'vue-router'
import axios from 'axios'
export default {
name: 'Test',
data () {
return {
count: 0
count: 0,
getData: { id: 1, title: 'title' }
}
},
methods: {
click () {
this.count++
},
async getPosts () {
axios.get('/api/posts').then(response => {
this.getData = response.data
})
}
},
created () {