cucumberjs-qase-reporter 2.0.0 → 2.0.2

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Publish results simple and easy.
4
4
 
5
- ## How to install
5
+ To install the latest version, run:
6
6
 
7
7
  ```sh
8
8
  npm install -D cucumberjs-qase-reporter
package/changelog.md CHANGED
@@ -1,3 +1,17 @@
1
+ # qase-cucumberjs@2.0.2
2
+
3
+ ## What's new
4
+
5
+ - Support `QaseIgnore` tag. If the test case has the `QaseIgnore` tag, the reporter will not send the result to the Qase
6
+ TMS.
7
+
8
+ ```cucumber
9
+ @QaseIgnore
10
+ Scenario: simple test
11
+ ```
12
+
13
+ - Improved error handling.
14
+
1
15
  # qase-cucumberjs@2.0.0
2
16
 
3
17
  ## What's new
package/dist/models.d.ts CHANGED
@@ -2,4 +2,5 @@ interface TestMetadata {
2
2
  ids: number[];
3
3
  fields: Record<string, string>;
4
4
  title: string | null;
5
+ isIgnore: boolean;
5
6
  }
package/dist/storage.d.ts CHANGED
@@ -97,5 +97,12 @@ export declare class Storage {
97
97
  */
98
98
  static stepStatusMap: Record<TestStepResultStatus, StepStatusEnum>;
99
99
  private parseTags;
100
+ /**
101
+ * @param {Pickle} pickle
102
+ * @param {number[]} ids
103
+ * @private
104
+ */
105
+ private getSignature;
106
+ private getError;
100
107
  }
101
108
  export {};
package/dist/storage.js CHANGED
@@ -7,6 +7,7 @@ const qaseIdRegExp = /^@[Qq]-?(\d+)$/g;
7
7
  const newQaseIdRegExp = /^@[Qq]ase[Ii][Dd]=(\d+)$/g;
8
8
  const qaseTitleRegExp = /^@[Qq]ase[Tt]itle=(.+)$/g;
9
9
  const qaseFieldsRegExp = /^@[Qq]ase[Ff]ields:(.+?)=(.+)$/g;
10
+ const qaseIgnoreRegExp = /^@[Qq]ase[Ii][Gg][Nn][Oo][Rr][Ee]$/g;
10
11
  class Storage {
11
12
  constructor() {
12
13
  /**
@@ -150,10 +151,11 @@ class Storage {
150
151
  if (!pickle) {
151
152
  return undefined;
152
153
  }
153
- let error;
154
- if (this.testCaseStartedErrors[tcs.id]?.length) {
155
- error = new Error(this.testCaseStartedErrors[tcs.id]?.join('\n\n'));
154
+ const metadata = this.parseTags(pickle.tags);
155
+ if (metadata.isIgnore) {
156
+ return undefined;
156
157
  }
158
+ const error = this.getError(tcs.id);
157
159
  let relations = null;
158
160
  const nodeId = pickle.astNodeIds[pickle.astNodeIds.length - 1];
159
161
  if (nodeId != undefined && this.scenarios[nodeId] != undefined) {
@@ -168,7 +170,6 @@ class Storage {
168
170
  },
169
171
  };
170
172
  }
171
- const metadata = this.parseTags(pickle.tags);
172
173
  return {
173
174
  attachments: [],
174
175
  author: null,
@@ -177,16 +178,17 @@ class Storage {
177
178
  start_time: null,
178
179
  end_time: null,
179
180
  duration: Math.abs(testCase.timestamp.seconds - tcs.timestamp.seconds),
180
- stacktrace: error?.stack ?? null,
181
+ stacktrace: error?.stacktrace ?? null,
181
182
  thread: null,
182
183
  },
183
184
  fields: metadata.fields,
184
- message: null,
185
+ message: error?.message ?? null,
185
186
  muted: false,
186
187
  params: {},
188
+ group_params: {},
187
189
  relations: relations,
188
190
  run_id: null,
189
- signature: '',
191
+ signature: this.getSignature(pickle, metadata.ids),
190
192
  steps: this.convertSteps(pickle.steps, tc),
191
193
  testops_id: metadata.ids.length > 0 ? metadata.ids : null,
192
194
  id: tcs.id,
@@ -238,6 +240,7 @@ class Storage {
238
240
  ids: [],
239
241
  fields: {},
240
242
  title: null,
243
+ isIgnore: false,
241
244
  };
242
245
  for (const tag of tags) {
243
246
  if (qaseIdRegExp.test(tag.name)) {
@@ -263,9 +266,38 @@ class Storage {
263
266
  // do nothing
264
267
  }
265
268
  }
269
+ if (qaseIgnoreRegExp.test(tag.name)) {
270
+ metadata.isIgnore = true;
271
+ }
266
272
  }
267
273
  return metadata;
268
274
  }
275
+ /**
276
+ * @param {Pickle} pickle
277
+ * @param {number[]} ids
278
+ * @private
279
+ */
280
+ getSignature(pickle, ids) {
281
+ let signature = pickle.uri.split('/').join('::')
282
+ + '::'
283
+ + pickle.name.toLowerCase().replace(/\s/g, '_');
284
+ if (ids.length > 0) {
285
+ signature += '::' + ids.join('::');
286
+ }
287
+ return signature;
288
+ }
289
+ getError(testCaseId) {
290
+ const testErrors = this.testCaseStartedErrors[testCaseId];
291
+ if (!testErrors) {
292
+ return undefined;
293
+ }
294
+ const error = new qase_javascript_commons_1.CompoundError();
295
+ testErrors.forEach((message) => {
296
+ error.addMessage(message);
297
+ error.addStacktrace(message);
298
+ });
299
+ return error;
300
+ }
269
301
  }
270
302
  exports.Storage = Storage;
271
303
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cucumberjs-qase-reporter",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Qase TMS CucumberJS Reporter",
5
5
  "homepage": "https://github.com/qase-tms/qase-javascript",
6
6
  "main": "./dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "license": "Apache-2.0",
41
41
  "dependencies": {
42
42
  "@cucumber/messages": "^22.0.0",
43
- "qase-javascript-commons": "^2.0.0-beta.8"
43
+ "qase-javascript-commons": "^2.2.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@cucumber/cucumber": ">=7.0.0"