如何将文件排除在伊斯坦布尔纽约市覆盖范围报告中

发布于 2025-02-13 21:26:37 字数 1120 浏览 1 评论 0原文

我只是想让基本的伊斯坦布尔纽约市排除在项目上工作的功能,但到目前为止我还不能。

我正在使用柏树在我的react.js应用程序上运行E2E测试。我的覆盖范围报告似乎还不错,除了不忽略我的排除数组中的文件。

我已经尝试将其添加到我的package.json文件:

"nyc": {
        "exclude": [
            "AddressFormatter.js"
        ]
    }

我尝试包括完整路径名src/contements/components/addressFormatter以及**/advericalFormatter。 JS

我还尝试使用以下内容使用.nycrc.json

{
    "reporter": ["lcov", "text-summary"],
    "sourceMap": true,
    "instrument": true,
    "temp-dir": "app/test/.nyc_output",
    "report-dir": "app/test/coverage",
    "all": true,
    "exclude": ["**/AddressFormatter.js"],
    "check-coverage": true
}

找到此问题的步骤。从终端i RAN

YARN ADD -D @CYPRESS/CODE -COVERAGE

然后我运行

YARN add -d nyc

接下来我ran ran ran

nyc nyc仪器./src ./覆盖范围

最后我更新了package.json

“ start”启动脚本:“ react-scripts -r @cypress/instrument-cra启动“

之后,我尝试了上述所有方法来获取我的覆盖范围报告以忽略不同的文件。

到目前为止,我还没有成功忽略此文件。任何建议将不胜感激。

I am just trying to get the basic Istanbul nyc exclude functionality working on my project but so far I cannot.

I am using Cypress to run e2e test on my react.js application. My coverage report seems to be working fine other than it not ignoring the files in my exclude array.

I have tried adding this to my package.json file:

"nyc": {
        "exclude": [
            "AddressFormatter.js"
        ]
    }

I have tried including the full path name src/components/AddressFormatter as well as **/AddressFormatter.js.

I have also tried using a .nycrc.json with the following content:

{
    "reporter": ["lcov", "text-summary"],
    "sourceMap": true,
    "instrument": true,
    "temp-dir": "app/test/.nyc_output",
    "report-dir": "app/test/coverage",
    "all": true,
    "exclude": ["**/AddressFormatter.js"],
    "check-coverage": true
}

The steps I took to find this problem. From the terminal I ran

yarn add -D @cypress/code-coverage

Then I ran

yarn add -D nyc

Next I ran

nyc instrument ./src ./coverage

Lastly I updated the package.json start script with

"start": "react-scripts -r @cypress/instrument-cra start"

After this I tried all of the methods above to get my coverage report to ignore different files.

So far I have had no success ignoring this file. Any suggestions would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欢烬 2025-02-20 21:26:37

在文档之后,您可以尝试一些选项:

  • 将Dubl Dexp Option添加到您的代码覆盖范围环境变量中:
// cypress.config.js or cypress.json
env: {
  codeCoverage: {
    exclude: ['**/AddressFormatter.*'],
  },
},
  • 使用exclududefterremap选项。引用repo readme

另一个重要选择是排除以下内容。默认情况下,它是错误的,它可能会允许将文件排除在外。如果您排除了文件,并且仪表符不尊重NYC.Exclude设置,请添加以下内容:

  • 最后,还有一个示例 repo 您可以将您的

Following the docs seems that there are a couple of options you can try:

  • Add the exclude option into your code coverage environment variable:
// cypress.config.js or cypress.json
env: {
  codeCoverage: {
    exclude: ['**/AddressFormatter.*'],
  },
},
  • Use the excludeAfterRemap option. Quoting the repo README:

Another important option is excludeAfterRemap. By default it is false, which might let excluded files through. If you are excluding the files, and the instrumenter does not respect the nyc.exclude setting, then add excludeAfterRemap: true to tell nyc report to exclude files.

  • Lastly there is an example repo you can compare yours with
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文