我添加了以下步骤以在Azure UI管道中为React UI运行单元测试。
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;
"scripts": {
....
"test": "jest"
},
devdependencies{
...
"jest": "^23.4.1",
"jest-trx-results-processor": "0.0.7",
"jsdom": "^11.12.0"
},
"jest": {
"testResultsProcessor": "./jestTrxProcessor.js",
"reporters": [
"default",
[
"jest-trx-results-processor",
{
"outputFile": "./jestTrxProcessor.js",
}
]]},
4.在yaml文件中,我添加了以下脚本:
script: |
npm install
npm run build
npm install jest-trx-results-processor --save-dev
yarn add --dev jest-trx-results-processor
npm run test
displayName: 'npm install and build'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: './jestTrxProcessor.js'
testRunTitle: 'FrontEnd Test'
在Azure Devops中运行管道后,出现以下错误:
找不到测试/ home / vsts / work / 1 / s已检查40个文件。testMatch:/测试/ / .js?(x),** /?(。)+(spec | test).js?(x)-0个匹配项testPathIgnorePatterns:/ node_modules /-40个匹配项
我已经搜索了此文件夹,并且在创建/存在的位置没有该文件夹。我没有得到我在这里想念的东西。我对创建用于React UI的yaml管道非常陌生。请帮助。先感谢您
找不到测试/ home / vsts / work / 1 / s已检查40个文件。testMatch:/tests//.js?(x),**/?(.)+(spec|test).js?(x)-0个匹配项testPathIgnorePatterns:/ node_modules /-40个匹配项
根据错误消息,开玩笑地测试是在文件__tests__
夹下找到xx.js文件。这是由于默认的testmatch规则。
我可以重现此问题。
要解决此问题,您需要更改以下设置:
__tests__
。2.在package.json中编辑testResultsProcessor路径。
这是一个例子:
"jest": {
"testResultsProcessor": "./__tests__/jestTrxProcessor",
"reporters": [
"default",
[
"jest-trx-results-processor",
{
"outputFile": "relative/path/to/resulting.trx"
}
]
]
}
结果:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句