diff --git a/lib/polyfills.js b/lib/polyfills.js new file mode 100644 index 0000000..f59b5c6 --- /dev/null +++ b/lib/polyfills.js @@ -0,0 +1,19 @@ +//! Was added to support NodeJS 10. +if (!Promise.allSettled) { + Promise.allSettled = function (promises) { + return Promise.all( + promises.map((p) => + Promise.resolve(p).then( + (value) => ({ + status: 'fulfilled', + value, + }), + (error) => ({ + status: 'rejected', + reason: error, + }), + ), + ), + ); + }; +} diff --git a/lib/report-portal-client.js b/lib/report-portal-client.js index b76de1d..b34ddac 100644 --- a/lib/report-portal-client.js +++ b/lib/report-portal-client.js @@ -7,6 +7,7 @@ const { getClientConfig } = require('./commons/config'); const Statistics = require('../statistics/statistics'); const { EVENT_NAME } = require('../statistics/constants'); const { RP_STATUSES } = require('./constants/statuses'); +require('./polyfills'); const MULTIPART_BOUNDARY = Math.floor(Math.random() * 10000000000).toString(); @@ -581,32 +582,38 @@ class RPClient { itemObj.finishSend = true; this.logDebug(`Finish all children for test item with tempId ${itemTempId}`); - Promise.all( + Promise.allSettled( itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish), - ).then( - () => { + ) + .then((results) => { + if (this.debug) { + results.forEach((result, index) => { + if (result.status === 'fulfilled') { + this.logDebug( + `Successfully finish child with tempId ${itemObj.children[index]} + of test item with tempId ${itemTempId}`, + ); + } else { + this.logDebug( + `Failed to finish child with tempId ${itemObj.children[index]} + of test item with tempId ${itemTempId}`, + ); + } + }); + } + this.cleanMap(itemObj.children); - this.logDebug( - `All children for test item with tempId ${itemTempId} successfully finished.`, - ); + this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ); this.finishTestItemPromiseStart( itemObj, itemTempId, Object.assign(finishTestItemData, { launchUuid: this.launchUuid }), ); - }, - () => { - this.cleanMap(itemObj.children); + }) + .catch(() => { this.logDebug(`Error finish children of test item with tempId ${itemTempId}`); - this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ); - this.finishTestItemPromiseStart( - itemObj, - itemTempId, - Object.assign(finishTestItemData, { launchUuid: this.launchUuid }), - ); - }, - ); + }); return { tempId: itemTempId,