Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support the issue test item #28

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -241,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
13 changes: 9 additions & 4 deletions helpers/rpHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions test/codecept.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down