@qavajs/format-report-portal 0.9.3 → 0.10.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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.10.0
2
+ - added support of named hooks
3
+ - added retries
4
+
5
+ ## 0.9.4
6
+ - fixed bug with finishing launch before all data sent
7
+
1
8
  ## 0.9.3
2
9
  - updated rp client version
3
10
 
package/README.MD CHANGED
@@ -17,7 +17,7 @@ module.exports = {
17
17
  rpConfig: {
18
18
  enable: true,
19
19
  debug: false,
20
- token: 'your token',
20
+ apiKey: 'your token',
21
21
  endpoint: 'https://your-rp-instance/api/v1',
22
22
  description: 'Description',
23
23
  tags: ['Tag'],
package/index.js CHANGED
@@ -16,19 +16,27 @@ class RPFormatter extends Formatter {
16
16
  this.rpConfig = options.parsedArgvOptions.rpConfig;
17
17
  this.rpClient = new RPClient(this.rpConfig);
18
18
  this.promiseQ = [];
19
+ this.stepDefinitions = {};
19
20
  }
20
21
 
21
22
  async processEnvelope(envelope) {
22
23
  try {
24
+ if (envelope.stepDefinition || envelope.hook) {
25
+ return this.readStepDefinition(envelope);
26
+ }
23
27
  if (envelope.testRunStarted) {
24
- await this.startLaunch();
28
+ const startLaunch = this.startLaunch();
29
+ this.promiseQ.push(startLaunch);
30
+ await startLaunch;
31
+ }
32
+ else if (envelope.testCaseFinished) {
33
+ const finishTest = this.finishTest(envelope)
34
+ this.promiseQ.push(finishTest);
35
+ await finishTest;
25
36
  }
26
37
  else if (envelope.testRunFinished) {
27
38
  await this.finishLaunch();
28
39
  }
29
- else if (envelope.testCaseFinished) {
30
- await this.finishTest(envelope);
31
- }
32
40
  } catch (err) {
33
41
  if (this.rpConfig.ignoreErrors) {
34
42
  console.error(err);
@@ -38,6 +46,11 @@ class RPFormatter extends Formatter {
38
46
  }
39
47
  }
40
48
 
49
+ readStepDefinition(stepDefinition) {
50
+ const definition = stepDefinition.stepDefinition ?? stepDefinition.hook;
51
+ this.stepDefinitions[definition.id] = definition;
52
+ }
53
+
41
54
  async startLaunch() {
42
55
  const launchObj = this.rpClient.startLaunch({
43
56
  name: this.rpConfig.launch,
@@ -50,7 +63,6 @@ class RPFormatter extends Formatter {
50
63
 
51
64
  this.launchId = launchObj.tempId;
52
65
  this.features = {};
53
- this.promiseQ.push(launchObj.promise);
54
66
  await launchObj.promise;
55
67
  }
56
68
 
@@ -65,7 +77,6 @@ class RPFormatter extends Formatter {
65
77
  }
66
78
 
67
79
  async finishTest(envelope) {
68
- if (envelope.testCaseFinished.willBeRetried) return;
69
80
  const testCase = this.eventDataCollector.getTestCaseAttempt(envelope.testCaseFinished.testCaseStartedId);
70
81
  const featureName = testCase.gherkinDocument.feature.name;
71
82
  if (!this.features[featureName]) {
@@ -80,7 +91,6 @@ class RPFormatter extends Formatter {
80
91
  type: 'SUITE'
81
92
  }, this.launchId);
82
93
  this.features[featureName] = featureItem.tempId;
83
- this.promiseQ.push(featureItem.promise);
84
94
  await featureItem.promise;
85
95
  }, this.rpConfig.retry);
86
96
  }
@@ -104,15 +114,16 @@ class RPFormatter extends Formatter {
104
114
  });
105
115
 
106
116
  // Start test
117
+ const retryTest = Boolean(testCase.attempt);
107
118
  const testItem = await retry(async () => {
108
119
  const testItem = this.rpClient.startTestItem({
109
120
  description: this.formatTags(testCase.pickle.tags),
110
121
  name: testCase.pickle.name,
111
122
  startTime,
112
123
  type: 'STEP',
113
- attributes
124
+ attributes,
125
+ retry: retryTest
114
126
  }, this.launchId, featureTempId);
115
- this.promiseQ.push(testItem.promise);
116
127
  await testItem.promise;
117
128
  return testItem;
118
129
  }, this.rpConfig.retry);
@@ -130,7 +141,6 @@ class RPFormatter extends Formatter {
130
141
  type: 'STEP',
131
142
  hasStats: false
132
143
  }, this.launchId, testItem.tempId);
133
- this.promiseQ.push(nestedTestItem.promise);
134
144
  await nestedTestItem.promise;
135
145
  return nestedTestItem;
136
146
  }, this.rpConfig.retry);
@@ -142,7 +152,6 @@ class RPFormatter extends Formatter {
142
152
  message: this.getMessage(step),
143
153
  time: startTime
144
154
  });
145
- this.promiseQ.push(log.promise);
146
155
  await log.promise;
147
156
  }, this.rpConfig.retry);
148
157
  }
@@ -158,7 +167,6 @@ class RPFormatter extends Formatter {
158
167
  status: this.getStatus(step),
159
168
  endTime
160
169
  });
161
- this.promiseQ.push(nestedItemFinish.promise);
162
170
  await nestedItemFinish.promise;
163
171
  startTime = endTime;
164
172
  }, this.rpConfig.retry);
@@ -172,12 +180,13 @@ class RPFormatter extends Formatter {
172
180
  status,
173
181
  endTime
174
182
  });
175
- this.promiseQ.push(testItemFinish.promise);
176
183
  await testItemFinish.promise;
177
184
  }
178
185
 
179
186
  getStepResults(testCase) {
180
187
  return testCase.testCase.testSteps.map(step => ({
188
+ id: step.id,
189
+ stepDefinitionId: step.pickleStepId ?? step.hookId,
181
190
  result: testCase.stepResults[step.id],
182
191
  pickle: testCase.pickle.steps.find(pickle => pickle.id === step.pickleStepId),
183
192
  attachment: testCase.stepAttachments[step.id] ?? []
@@ -198,6 +207,8 @@ class RPFormatter extends Formatter {
198
207
  }
199
208
 
200
209
  hookKeyword(step, steps) {
210
+ const hook = this.stepDefinitions[step.stepDefinitionId];
211
+ if (hook?.name) return hook.name;
201
212
  const stepsBefore = steps.slice(0, steps.findIndex((element) => element === step));
202
213
  return stepsBefore.every(element => element.pickle === undefined) ? 'Before' : 'After'
203
214
  }
@@ -258,7 +269,6 @@ class RPFormatter extends Formatter {
258
269
  time: startTime
259
270
  }, attachmentData);
260
271
  }
261
- this.promiseQ.push(log.promise);
262
272
  await log.promise;
263
273
  }
264
274
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qavajs/format-report-portal",
3
- "version": "0.9.3",
3
+ "version": "0.10.0",
4
4
  "description": "cucumber formatter for report portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "@reportportal/client-javascript": "^5.0.12"
24
24
  },
25
25
  "devDependencies": {
26
- "@cucumber/cucumber": "^9.1.2",
26
+ "@cucumber/cucumber": "^9.2.0",
27
27
  "@qavajs/cli": "^0.26.0",
28
28
  "@qavajs/memory": "^1.5.1"
29
29
  }