繁体   English   中英

运行 VSTest 时解析结果文件失败 Azure pipelines

[英]Failed to parse result files when VSTest is run Azure pipelines

我添加了以下步骤以在 Azure 管道中为 React UI 运行单元测试。

添加了一个文件,文件名:jestTrxProcessor.js。 内容:

 var builder = require("jest-trx-results-processor/dist/testResultsProcessor"); var builder = require("jest-trx-results-processor"); var processor = builder({ outputFile: "jestTestresults.trx", }); module.exports = processor;

  1. 在 package.json 我输入了以下代码:
"scripts": {
....
"test": "jest"
},
devdependencies{
 ...
 "jest": "^23.4.1",
  "jest-trx-results-processor": "0.0.7",
  "jsdom": "^11.12.0"
},
"jest": {
       "testResultsProcessor": "./__tests__/jestTrxProcessor.js",
    "reporters": [
"default",
[
  "jest-trx-results-processor",
  {
    "outputFile": "./__tests__/jestTestresults.trx",
  
  }
]]},

3.在 yaml 文件中,我添加了以下脚本:

- script: |
    npm install
    npm install jest-trx-results-processor --save-dev
    yarn add --dev jest-trx-results-processor
    npm run build
 
   # npm run test
  displayName: 'npm install and build'
  
- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'VSTest'
    testResultsFiles: './__tests__/jestTestresults.trx'
    testRunTitle: 'FrontEnd Test'

我收到以下错误:

在此处输入图像描述

运行 VSTest 时解析结果文件失败 Azure pipelines

根据错误信息:

发布测试结果无法解析结果文件:System.Xml.XmlException:根级别的数据无效。 1号线,position 1

这意味着您尝试解析不是 XML 文档的内容,或者生成的 trx 文件存在问题。

要解决此问题,请尝试更新 devdependencies jest jest-trx-results-processor

  "devDependencies": {
    "jest": "^26.6.3",
    "jest-trx-results-processor": "~2.0.0"
  },

并尝试 select JUnitTestResultsFormat

在此处输入图像描述

此外, Jest testResultsProcessor 属性已弃用,请尝试使用 jest-junit package 获取测试报告:

请检查此线程以获取更多详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM