javascript - 在来自 Karma-JUnit-Reporter 的 JUnit xml 文件中包含文件名
问题描述
我需要找到一种方法在 JUnit XML 结果文件中包含某个测试的文件名。它只包含类名:
<testcase name="xxxTest should do Y." time="0.119" classname="Chrome_80_0_3987_(Mac_OS_X_10_12_6).xxxTest">
classNameFormatter
在文件中创建报告配置时有一个选项可以传入karma.conf.js
,但不确定是否有办法使用它来检索文件名?
// karma.conf.js
// the default configuration
junitReporter: {
outputDir: '', // results will be saved as $outputDir/$browserName.xml
outputFile: undefined, // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: '', // suite will become the package name attribute in xml testsuite element
useBrowserName: true, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
properties: {}, // key value pair of properties to add to the <properties> section of the report
xmlVersion: null // use '1' if reporting to be per SonarQube 6.2 XML format
}
解决方案
你可以这样做:
classNameFormatter: function(browser, result) {
return result.suite[0];
},
您可以记录输入(浏览器和结果)的结构,以了解您拥有哪些数据:
console.dir(result);
希望能帮助到你!
推荐阅读
- go - 在 Jenkins 中使用私有存储库中的依赖项构建 go 项目
- database - 将数据从非规范化表加载到另一个表 - PostgreSQL11
- python-3.x - 如何在 Python 中调用带参数的调用 JMX 操作?
- r - 使用 countif 计算对数据进行分组和汇总
- express-gateway - 创建凭据时卡住 - 通过 package.json 的 Yargs 已弃用
- javascript - 使用 axios 的 400 错误请求
- php - @oci_fetch_all 返回正确长度的二维数组,但行为空
- python - 全连接层大小
- html - Devtools 在表达上中断
- kubernetes - 如何在 Kubernetes 部署或 StatefulSet 之间创建依赖关系