我需要帮助来查找代码覆盖率。
我刚刚使用最新的 create-react-app 创建了一个新应用程序。
我正在尝试使用npm run test -- --coverage
查找代码覆盖率。这显示了空代码覆盖率。任何人都可以帮我找到我失踪的地方。
PASS src/__tests__/App.test.js
✓ renders without crashing (2ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.17s, estimated 1s
Ran all test suites.
Watch Usage: Press w to show more.
最佳答案
https://github.com/facebook/create-react-app/issues/6888
只需将标志 --watchAll=false
添加到您的 npm run test -- --coverage
关于reactjs - 为什么react应用程序中的代码覆盖率是空的?尝试使用 npm run test -- --coverage。但总是显示空代码覆盖率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57034062/