billylam / wdio-wdiov5testrail-reporter

https://www.npmjs.com/package/wdio-wdiov5testrail-reporter
MIT License
6 stars 8 forks source link

Error on publishing empty results #14

Closed AliakseiBulat closed 2 years ago

AliakseiBulat commented 2 years ago

Exception occurs in case if you don't have TestRail test case ids in your test run.

For some reason this exception is not getting printed and test execution looks correct, but process fails (at least it fail the job on CI).

Solution:

  1. Add additional validation of rawResults array size (line 38):
  2. add additional validation of size and return in case if there are not results to publish (without creation of a new test run) (line 46)

src/utils.js

if ( rawResults && rawResults.length && Object.prototype.hasOwnProperty.call(rawResults[0], 'cid') ) { createTestPlan = true; rawResults.forEach((result) => { if (!groupedResults[result.cid]) groupedResults[result.cid] = [result]; else groupedResults[result.cid].push(result); }); } else { if (!rawResults.length) { console.log('[wdio-wdiov5testrail-reporter] No results to publish in TestRail') return; } groupedResults = [rawResults]; }

NOTE: I would have created a branch and a PR, but it looks like i don't have enough permissions.

billylam commented 2 years ago

Thanks. I published 1.0.33, opting to just verify rawResults.length after parsing all files. Let me know if you see any more issues.

NOTE: I would have created a branch and a PR, but it looks like i don't have enough permissions.

Just for future reference you usually create a fork first and make the pull request back upstream on GitHub. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

AliakseiBulat commented 2 years ago

It works! Thx for the tip with forking.