I have added the below steps to run unit test in Azure pipelines for React UI.
Added a file , File name:jestTrxProcessor.js. The content:
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;
- In package.json I entered the below code:
"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.In the yaml file I added the below script:
- 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'
I am getting the below error: