首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以运行React App或使用babel-jest对其进行测试

我可以运行React App或使用babel-jest对其进行测试
EN

Stack Overflow用户
提问于 2019-11-15 09:00:07
回答 1查看 1.2K关注 0票数 1

我正在尝试为现有的React应用程序设置测试。经过一番努力,我们正在使用React 16.8.13,我已经让它工作了。为此,我不得不安装jest 24.9.0babel-jest 24.9.0。测试运行得很好,我得到了一份覆盖率报告。然而,当我运行yarn start时,我得到了一个错误:

代码语言:javascript
复制
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中删除jestbabel-jest可以解决这个问题,但是现在运行yarn test会给我一个错误:

代码语言:javascript
复制
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.

我需要做什么才能让应用程序和测试都可运行?

EN

回答 1

Stack Overflow用户

发布于 2019-11-15 09:05:45

根据No tests found,看起来您的测试可能不在正确的文件夹中。它们应该位于src中名为__tests__的文件夹中,并带有test.jsspec.js后缀。

有关更多信息,请参阅此答案:Create React App cannot find tests

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58868823

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档