用vite搭建的vue3项目没有带单元测试功能,后期想添加这功能,我的思路是用vue-cli搭建一个有单元测试的空框架,然后把单元测试需要的文件复制到项目中。如果项目中有TS,创建项目的时候就要把ts也一起创建。
需要复制的文件有:
1.readme
# jesttwo
## Project setup
npm install
### Compiles and hot-reloads for development
npm run serve
### Compiles and minifies for production
npm run build
### Run your unit tests
npm run test:unit
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
2.tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
3.package.json
{
"name": "jesttwo",
"version": "0.1.0",