【发布时间】:2020-03-11 02:56:45
【问题描述】:
我正在尝试为现有的 React 应用程序设置测试。我们正在使用React 16.8.13
经过一番挣扎,我已经成功了。为此,我必须安装 jest 24.9.0 和 babel-jest 24.9.0。测试运行良好,我得到了覆盖率报告。但是,当我运行 yarn start 时出现错误:
The react-scripts package provided by Create React App requires a dependency:
"babel-jest": "23.6.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in the tree:
/<Path to my App>/node_modules/babel-jest (version: 24.9.0)
从devDependencies 中删除jest 和babel-jest 解决了这个问题,但现在运行yarn test 给我一个错误:
No tests found
In /<Path to my App>
32 files checked.
testMatch: - 32 matches
testPathIgnorePatterns: /node_modules/ - 32 matches
testRegex: (\/tests\/.*\.test)\.[jt]sx?$ - 0 matches
Pattern: - 0 matches
error Command failed with exit code 1.
我需要做什么才能让应用程序和测试都可以运行?
【问题讨论】:
标签: reactjs jestjs babel-jest