@qavajs/format-report-portal 0.9.4 → 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,7 @@
1
+ ## 0.10.0
2
+ - added support of named hooks
3
+ - added retries
4
+
1
5
  ## 0.9.4
2
6
  - fixed bug with finishing launch before all data sent
3
7
 
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,10 +16,14 @@ 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
28
  const startLaunch = this.startLaunch();
25
29
  this.promiseQ.push(startLaunch);
@@ -42,6 +46,11 @@ class RPFormatter extends Formatter {
42
46
  }
43
47
  }
44
48
 
49
+ readStepDefinition(stepDefinition) {
50
+ const definition = stepDefinition.stepDefinition ?? stepDefinition.hook;
51
+ this.stepDefinitions[definition.id] = definition;
52
+ }
53
+
45
54
  async startLaunch() {
46
55
  const launchObj = this.rpClient.startLaunch({
47
56
  name: this.rpConfig.launch,
@@ -68,7 +77,6 @@ class RPFormatter extends Formatter {
68
77
  }
69
78
 
70
79
  async finishTest(envelope) {
71
- if (envelope.testCaseFinished.willBeRetried) return;
72
80
  const testCase = this.eventDataCollector.getTestCaseAttempt(envelope.testCaseFinished.testCaseStartedId);
73
81
  const featureName = testCase.gherkinDocument.feature.name;
74
82
  if (!this.features[featureName]) {
@@ -106,13 +114,15 @@ class RPFormatter extends Formatter {
106
114
  });
107
115
 
108
116
  // Start test
117
+ const retryTest = Boolean(testCase.attempt);
109
118
  const testItem = await retry(async () => {
110
119
  const testItem = this.rpClient.startTestItem({
111
120
  description: this.formatTags(testCase.pickle.tags),
112
121
  name: testCase.pickle.name,
113
122
  startTime,
114
123
  type: 'STEP',
115
- attributes
124
+ attributes,
125
+ retry: retryTest
116
126
  }, this.launchId, featureTempId);
117
127
  await testItem.promise;
118
128
  return testItem;
@@ -175,6 +185,8 @@ class RPFormatter extends Formatter {
175
185
 
176
186
  getStepResults(testCase) {
177
187
  return testCase.testCase.testSteps.map(step => ({
188
+ id: step.id,
189
+ stepDefinitionId: step.pickleStepId ?? step.hookId,
178
190
  result: testCase.stepResults[step.id],
179
191
  pickle: testCase.pickle.steps.find(pickle => pickle.id === step.pickleStepId),
180
192
  attachment: testCase.stepAttachments[step.id] ?? []
@@ -195,6 +207,8 @@ class RPFormatter extends Formatter {
195
207
  }
196
208
 
197
209
  hookKeyword(step, steps) {
210
+ const hook = this.stepDefinitions[step.stepDefinitionId];
211
+ if (hook?.name) return hook.name;
198
212
  const stepsBefore = steps.slice(0, steps.findIndex((element) => element === step));
199
213
  return stepsBefore.every(element => element.pickle === undefined) ? 'Before' : 'After'
200
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qavajs/format-report-portal",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
4
4
  "description": "cucumber formatter for report portal",
5
5
  "main": "index.js",
6
6
  "scripts": {