gpt4 book ai didi

reactjs - 开 Jest - 覆盖率报告现在显示所有文件

转载 作者:行者123 更新时间:2023-12-05 02:33:30 28 4
gpt4 key购买 nike

我正在手动设置 Jest 。

我的 repo 结构:

my-proj
- src
- components
...
- accordion
- index.jsx
- tests
- components
- accordion.test.js
- setupTests.js
- package.json

当我运行 npm run test-coverage为了获得测试覆盖率,它只返回我测试过的文件而不是 /src 中的所有文件.

enter image description here

包.json

  "scripts": {
"test": "jest --watchAll",
"test-coverage": "jest --coverage",
},
"jest": {
"moduleDirectories": [
"node_modules",
"src"
],
"moduleNameMapper": {
"\\.(css|scss)$": "identity-obj-proxy"
},
"setupFilesAfterEnv": [
"<rootDir>/src/setupTests.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
},

最佳答案

我刚刚偶然发现你的问题和你有同样的问题。尝试运行 jest --coverage --watchAll。这应该涵盖所有文件覆盖范围并显示哪些不是,即使没有测试文件也是如此。

关于reactjs - 开 Jest - 覆盖率报告现在显示所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70985136/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com