feat: 解决vue组件单元测试复杂的环境依赖,以及提交NetworkOverviewLine单元测试用例
This commit is contained in:
14
src/Test.vue
14
src/Test.vue
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user