gpt4 book ai didi

javascript - 实习生覆盖范围不包括卸载源

转载 作者:行者123 更新时间:2023-12-03 02:02:50 26 4
gpt4 key购买 nike

Intern测试不加载源文件(0%覆盖)时,它们不会显示在(lcov)覆盖率报告(在nodejs中运行)中。

我认为这通常是 JS 工具难以解决的问题。

例如开玩笑有一个 simple workaround .

我正在为实习生寻找最简单的解决方法,最好使用 v3。

  • 由于 Intern 在幕后使用 istanbul,想知道是否 --include-all-source flag 有效并且可以轻松通过吗?
  • 是否有一个标准方法可以让加载程序了解所有文件?
  • 我的文件在 Nodejs 中也无法很好地加载,可以将它们包含进来吗?

最佳答案

看看实习生项目本身以及config script有一个名为coverage的选项,覆盖率定义为:

An array of file paths or globs that should be instrumented for code coverage, or false to completely disable coverage. This property should point to the actual JavaScript files that will be executed, not pre-transpiled sources (coverage results will still be mapped back to original sources). Coverage data will be collected for these files even if they’re not loaded by Intern for tests, ALLOWING A TEST WRITER TO SEE WHICH FILES HAVENT BEEN TESTED writer to see which files haven’t been tested, as well as coverage on files that were tested. When this value is unset, Intern will still look for coverage data on a global coverage variable, and it will request coverage data from remote sessions. Explicitly setting coverage to false will prevent Intern from even checking for coverage data. 💡This property replaces the excludeInstrumentation property used in previous versions of Intern, which acted as a filter rather than an inclusive list.

抱歉使用大写字母,只是为了突出显示该句子。覆盖范围使用 glob就像 Istanbul 尔一样,因此您可以指定类似 coverage: ['src/**/*.js'] 的内容。

我意识到这一点是因为实习生本身使用 this configuration收集报道,这似乎对他们有用。

编辑:正如评论中指出的,此功能仅出现在实习生 v4 中。

关于javascript - 实习生覆盖范围不包括卸载源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49936475/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com