vue3添加单元测试

用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",
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值