feat: 增加单元测试功能
This commit is contained in:
28
src/Test.vue
Normal file
28
src/Test.vue
Normal file
@@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<span data-test="count">{{count}}</span>
|
||||
<button data-test="button" @click="click">click</button>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/* vue-jest的测试示例 */
|
||||
import VueRouter from 'vue-router'
|
||||
export default {
|
||||
name: 'Test',
|
||||
data () {
|
||||
return {
|
||||
count: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
click () {
|
||||
this.count++
|
||||
}
|
||||
},
|
||||
created () {
|
||||
const { currentRoute } = VueRouter.useRouter()
|
||||
return {
|
||||
currentRoute
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,37 +0,0 @@
|
||||
module.exports = {
|
||||
globals: {
|
||||
// work around: https://github.com/kulshekhar/ts-jest/issues/748#issuecomment-423528659
|
||||
'ts-jest': {
|
||||
diagnostics: {
|
||||
ignoreCodes: [151001]
|
||||
}
|
||||
}
|
||||
},
|
||||
testEnvironment: 'jsdom',
|
||||
transform: {
|
||||
'^.+\\.vue$': 'vue-jest',
|
||||
'^.+\\.(t|j)sx?$': [
|
||||
'babel-jest', {
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
node: true
|
||||
}
|
||||
}
|
||||
],
|
||||
'@babel/preset-typescript'
|
||||
],
|
||||
plugins: [
|
||||
'@vue/babel-plugin-jsx',
|
||||
'@babel/plugin-proposal-class-properties'
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
||||
// u can change this option to a more specific folder for test single component or util when dev
|
||||
// for example, ['<rootDir>/packages/input']
|
||||
roots: ['<rootDir>']
|
||||
}
|
||||
@@ -31,10 +31,6 @@ const routes = [
|
||||
path: '/detection/:typeName',
|
||||
component: () => import('@/views/detections/Index')
|
||||
},
|
||||
{
|
||||
path: '/temp',
|
||||
component: () => import('@/views/Temp')
|
||||
},
|
||||
{
|
||||
path: '/businessLog/viewer',
|
||||
component: () => import('@/views/businessLog/Viewer')
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<template>
|
||||
<div>Temp</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Temp'
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user