Skip to content

Commit 32b7748

Browse files
Mykhailo BodnarchukMykhailo Bodnarchuk
Mykhailo Bodnarchuk
authored and
Mykhailo Bodnarchuk
committed
added event to receive report
1 parent 3a14b93 commit 32b7748

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.2.3
2+
3+
* added `reportportal.result` event to notify when report was created
4+
15
# 0.2.0
26

37
* Added debug messages logs

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ reportPortal.addLog({
8484

8585
See [`sendLog` method of ReportPortal JavaScript Client](https://github.com/reportportal/client-javascript#sendlog) for more oprtions.
8686

87+
### Get Report URL
88+
89+
Once report is posted a special `reportportal.result` event is created.
90+
91+
You can use it to pass URL of a report into other plugins. For instance, you can use it to send Slack or Email notifications including a link to a report.
92+
93+
```js
94+
// inside your custom plugin:
95+
event.dispatcher.on('reportportal.result', (result) => {
96+
// use result.link as URL to report
97+
console.log('Report was published at', result.link);
98+
})
99+
```
100+
87101
## Todo
88102

89103
- [ ] Support `run-workers` command to aggregate all tests under one launch.

index.js

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module.exports = (config) => {
5151
if (!config[field]) throw new Error(`ReportPortal config is invalid. Key ${field} is missing in config.\nRequired fields: ${requiredFields} `)
5252
}
5353

54+
let reportUrl;
5455
let launchObj;
5556
let suiteObj;
5657
let testObj;
@@ -282,7 +283,9 @@ module.exports = (config) => {
282283

283284
const response = await launch.promise;
284285

286+
reportUrl = response.link;
285287
output.print(` 📋 Report #${response.number} saved ➡`, response.link);
288+
event.emit('reportportal.result', response);
286289
} catch (error) {
287290
console.log(error);
288291
debug(error);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reportportal/agent-js-codecept",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Reportportal plugin for Codecept JS tests",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)