From 44f9ac5c532066be68b185553e49e095f1d88e4f Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Fri, 19 Jan 2024 11:13:04 +0100 Subject: [PATCH 1/2] feat: support the issue test item --- README.md | 1 + helpers/rpHelpers.js | 13 +++++++++---- index.js | 2 +- test/codecept.conf.js | 6 ++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index df36d0c..cd86351 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ To use this plugin you need to provide the following info: - `debug`: to turn on the debug for reportportal - `rerun`: to enable rerun - `rerunOf`: UUID of launch you want to rerun. If not specified, report portal will update the latest launch with the same name +- `issue`: Test item issue object. issueType is required, allowable values: 'pb***', 'ab***', 'si***', 'ti***', 'nd001'. Where *** is locator id. More info: https://github.com/reportportal/client-javascript?tab=readme-ov-file#finishtestitem ``` To show more logs: set `debug: true` in the configuration. diff --git a/helpers/rpHelpers.js b/helpers/rpHelpers.js index 6d75655..7bdfde3 100644 --- a/helpers/rpHelpers.js +++ b/helpers/rpHelpers.js @@ -81,15 +81,20 @@ async function startTestItem(launchId, testTitle, method, parentId = null, paren } } -async function finishTestItem(test) { +async function finishTestItem(test, issueObject) { if (!test) return; debug(`Finishing '${test.toString()}' Test`); - - rpClient.finishTestItem(test.tempId, { + const testItemRQ = { endTime: rpClient.helpers.now(), status: rpStatus(test.status), - }); + } + + if (issueObject) { + testItemRQ.issue = issueObject; + } + + rpClient.finishTestItem(test.tempId, testItemRQ); } async function finishStepItem(step) { diff --git a/index.js b/index.js index 2aa368f..a2c0a5b 100644 --- a/index.js +++ b/index.js @@ -168,7 +168,7 @@ module.exports = (config) => { const message = `${PREFIX_FAILED_TEST} - ${test.title}\n${test.err.stack ? test.err.stack : JSON.stringify(test.err)}`; await sendLogToRP({tempId: testObj.tempId, level: LOG_LEVELS.ERROR, message}); - await finishTestItem(testObj); + await finishTestItem(testObj, config.issue); } for (test of testArr.skipped) { diff --git a/test/codecept.conf.js b/test/codecept.conf.js index 7a68b1b..02de298 100644 --- a/test/codecept.conf.js +++ b/test/codecept.conf.js @@ -36,11 +36,17 @@ exports.config = { launchAttributes: [{ key: 'yourKey', value: 'yourValue', + }, { + key: 'platform', value: process.platform }], projectName: 'default_personal', rerun: false, debug: true, enabled: true, + issue: { + issueType: 'pb001', + comment: 'found by automated tests', + } }, }, tests: './*_test.js', From cc2e8cf176cdbd4c383613a84a25fbaa66d71d1b Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Fri, 19 Jan 2024 11:15:00 +0100 Subject: [PATCH 2/2] fix(docs): update video --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd86351..8e567fe 100644 --- a/README.md +++ b/README.md @@ -242,4 +242,4 @@ Success finish item with tempId ai1m1nxblq7zmzor { ## Video -https://github.com/kobenguyent/codeceptjs-rphelper/assets/7845001/c006723c-044b-4a5a-ad82-ddf9a08a5787 +https://github.com/kobenguyent/codeceptjs-rphelper/assets/7845001/f2a84ed1-acae-46f7-a611-90345e0a43c9