create-react-app 使用中相关问题整理

Published: · LastMod: May 14, 2022 · 55 words

1.test添加代码覆盖率 🔗

命令修改为

1
react-scripts test --coverage --watchAll=false

package.json

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
"jest": {
  "collectCoverageFrom": [
    "src/**/*.{js,jsx,ts,tsx}",
    "!<rootDir>/node_modules/"
  ],
  "coverageThreshold": {
    "global": {
      "lines": 90,
      "statements": 90
    }
  }
}