代码之家  ›  专栏  ›  技术社区  ›  Dimitri Kopriwa

如何将名为test.js的源排除在create react应用程序的测试文件之外?

  •  0
  • Dimitri Kopriwa  · 技术社区  · 6 年前

    /src/config/env/test.js

    不幸的是,jest现在试图将其作为测试来执行,

    我已尝试在我的报告中添加以下内容 package.json :

    "jest": {
        "collectCoverageFrom": [
          "!<rootDir>/src/config/env/test.js",
          "!<rootDir>/node_modules/"
        ]
    }
    

    但我仍然有一个错误:

    FAIL src/config/env/test.js
      ● Test suite failed to run
    
        Your test suite must contain at least one test.
    
          at node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:256:22
    

    我正在使用 反应脚本 2.1.3

    1 回复  |  直到 6 年前
        1
  •  2
  •   kix    6 年前

    这里最简单的解决方案是使用 testPathIgnorePatterns configuration value ,例如:

    "testPathIgnorePatterns": ["\/test.js"]
    
    推荐文章