maciejmaciejewski / azure-pipelines-postman

MIT License
12 stars 9 forks source link

Update index.js #16

Open anish-george88 opened 3 years ago

anish-george88 commented 3 years ago

This is to fix the null exception in Azure pipeline while exporting html result file.

[warning]TypeError: Cannot read property '1' of null checkIfSuccessful

ekav555 commented 1 year ago

@anish-george88 This fixed the error, but caused another.

[warning]TypeError: Assignment to constant variable.

at checkIfSuccessful (/home/ekavanaghadm/myagent/_work/_tasks/UploadPostmanHtmlReport_f5384bf0-1b5c-11ea-b0cc-5b064956a213/1.1.3/index.js:65:12)
at files.forEach.file (/home/ekavanaghadm/myagent/_work/_tasks/UploadPostmanHtmlReport_f5384bf0-1b5c-11ea-b0cc-5b064956a213/1.1.3/index.js:34:20)
at Array.forEach (<anonymous>)
at run (/home/ekavanaghadm/myagent/_work/_tasks/UploadPostmanHtmlReport_f5384bf0-1b5c-11ea-b0cc-5b064956a213/1.1.3/index.js:18:9)
at Object.<anonymous> (/home/ekavanaghadm/myagent/_work/_tasks/UploadPostmanHtmlReport_f5384bf0-1b5c-11ea-b0cc-5b064956a213/1.1.3/index.js:97:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
ekav555 commented 1 year ago

@anish-george88` this fixed it for me.

function checkIfSuccessful (document) { const text = document("div.card-header").find("a:contains('Failed Tests')").text() var result = 0 if(text != null){ if(text.match(template) != null){ result = new Number(text.match(template)[1]) } } return result > 0 ? false : true }