实习生报道不包括卸载源

Intern coverage not including unloaded sources

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

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

例如Jest 有一个 simple workaround.

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

查看实习生项目本身,在 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.

对不起,大写,只是为了突出句子。 coverage 与伊斯坦布尔一样使用 glob,因此您可以指定类似 coverage: ['src/**/*.js'].

的内容

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

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