@qavajs/format-report-portal 0.0.8 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.MD +3 -0
- package/README.MD +15 -3
- package/index.js +16 -4
- package/package.json +6 -6
package/CHANGELOG.MD
CHANGED
package/README.MD
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
## @qavajs/format-report-portal
|
|
2
2
|
This package is formatter for EPAM report portal
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Install
|
|
5
5
|
`npm install @qavajs/format-report-portal`
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Configuration
|
|
8
8
|
|
|
9
9
|
add formatter to config.js
|
|
10
10
|
```javascript
|
|
@@ -31,7 +31,19 @@ module.exports = {
|
|
|
31
31
|
```
|
|
32
32
|
Option `enable` is set to `true` even if it is not defined explicitly in rpConfig section.
|
|
33
33
|
|
|
34
|
-
###
|
|
34
|
+
### Test Level Attributes
|
|
35
|
+
Test level attributes can be added via cucumber logs e.g. in Before hook
|
|
36
|
+
```javascript
|
|
37
|
+
const { Before } = require('@cucumber/cucumber');
|
|
38
|
+
|
|
39
|
+
Before(function () {
|
|
40
|
+
this.log('log from before'); //just log
|
|
41
|
+
this.log(`rp_attribute: fixed:42`); //static attribute
|
|
42
|
+
this.log(`rp_attribute: random:${Date.now()}`); //dynamic attribute
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Run E2E Test
|
|
35
47
|
add token.json file with rp token and other config
|
|
36
48
|
run
|
|
37
49
|
`npm run test-e2e`
|
package/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
const { Formatter, Status } = require('@cucumber/cucumber');
|
|
2
2
|
const RPClient = require('@reportportal/client-javascript');
|
|
3
|
+
|
|
4
|
+
const RP_ATTRIBUTE_PREFIX = /^rp_attribute:\s*/;
|
|
5
|
+
const isAttribute = (attachment) => attachment.mediaType === 'text/x.cucumber.log+plain' && RP_ATTRIBUTE_PREFIX.test(attachment.body)
|
|
6
|
+
|
|
3
7
|
class RPFormatter extends Formatter {
|
|
4
8
|
launchId = null;
|
|
5
9
|
|
|
@@ -73,18 +77,25 @@ class RPFormatter extends Formatter {
|
|
|
73
77
|
const featureTempId = this.features[featureName];
|
|
74
78
|
let startTime = this.rpClient.helpers.now();
|
|
75
79
|
let endTime;
|
|
76
|
-
|
|
80
|
+
const steps = this.getStepResults(testCase);
|
|
81
|
+
const attributes = steps.reduce((attachments, step) => {
|
|
82
|
+
const attrs = step.attachment
|
|
83
|
+
.filter(isAttribute)
|
|
84
|
+
.map(attachment => attachment.body.replace(RP_ATTRIBUTE_PREFIX, ''));
|
|
85
|
+
return [...new Set([...attachments, ...attrs])]
|
|
86
|
+
}, []);
|
|
87
|
+
// Start test
|
|
77
88
|
const testItem = this.rpClient.startTestItem({
|
|
78
89
|
description: this.formatTags(testCase.pickle.tags),
|
|
79
90
|
name: testCase.pickle.name,
|
|
80
91
|
startTime,
|
|
81
|
-
type: 'STEP'
|
|
92
|
+
type: 'STEP',
|
|
93
|
+
attributes
|
|
82
94
|
}, this.launchId, featureTempId);
|
|
83
95
|
this.promiseQ.push(testItem.promise);
|
|
84
96
|
await testItem.promise;
|
|
85
97
|
|
|
86
98
|
//send steps
|
|
87
|
-
const steps = this.getStepResults(testCase)
|
|
88
99
|
for (const step of steps) {
|
|
89
100
|
const duration = step.result.duration;
|
|
90
101
|
endTime = startTime + (duration.seconds * 1_000) + Math.floor(duration.nanos / 1_000_000);
|
|
@@ -136,7 +147,7 @@ class RPFormatter extends Formatter {
|
|
|
136
147
|
return testCase.testCase.testSteps.map(step => ({
|
|
137
148
|
result: testCase.stepResults[step.id],
|
|
138
149
|
pickle: testCase.pickle.steps.find(pickle => pickle.id === step.pickleStepId),
|
|
139
|
-
attachment: testCase.stepAttachments[step.id]
|
|
150
|
+
attachment: testCase.stepAttachments[step.id] ?? []
|
|
140
151
|
}))
|
|
141
152
|
}
|
|
142
153
|
|
|
@@ -194,6 +205,7 @@ class RPFormatter extends Formatter {
|
|
|
194
205
|
|
|
195
206
|
async sendAttachment(attachment, testItem, startTime) {
|
|
196
207
|
let log;
|
|
208
|
+
if (attachment.mediaType === 'text/x.cucumber.log+plain' && RP_ATTRIBUTE_PREFIX.test(attachment.body)) return;
|
|
197
209
|
if (attachment.mediaType === 'text/x.cucumber.log+plain') {
|
|
198
210
|
log = await this.rpClient.sendLog(testItem.tempId, {
|
|
199
211
|
level: 'INFO',
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qavajs/format-report-portal",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "cucumber formatter for report portal",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test
|
|
7
|
+
"test:e2e": "qavajs run --config test-e2e/config.js"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/qavajs/format-report-portal#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@reportportal/client-javascript": "^5.0.
|
|
23
|
+
"@reportportal/client-javascript": "^5.0.10"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@cucumber/cucumber": "^9.1.
|
|
27
|
-
"@qavajs/cli": "^0.0.
|
|
28
|
-
"@qavajs/memory": "^1.
|
|
26
|
+
"@cucumber/cucumber": "^9.1.2",
|
|
27
|
+
"@qavajs/cli": "^0.0.24",
|
|
28
|
+
"@qavajs/memory": "^1.4.1"
|
|
29
29
|
}
|
|
30
30
|
}
|