cucumberjs-qase-reporter 2.1.6 → 2.1.8

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,15 @@
1
+ # qase-cucumberjs@2.1.8
2
+
3
+ ## What's new
4
+
5
+ - Improved support for QaseParameters and QaseGroupParameters tags.
6
+
7
+ # qase-cucumberjs@2.1.7
8
+
9
+ ## What's new
10
+
11
+ - Added support for QaseParameters and QaseGroupParameters tags.
12
+
1
13
  # qase-cucumberjs@2.1.6
2
14
 
3
15
  ## Bug fixes
package/dist/models.d.ts CHANGED
@@ -3,6 +3,8 @@ export interface TestMetadata {
3
3
  fields: Record<string, string>;
4
4
  title: string | null;
5
5
  isIgnore: boolean;
6
+ parameters: Record<string, string>;
7
+ group_params: Record<string, string>;
6
8
  }
7
9
  export interface ScenarioData {
8
10
  name: string;
package/dist/storage.d.ts CHANGED
@@ -100,10 +100,19 @@ export declare class Storage {
100
100
  /**
101
101
  * @param {Pickle} pickle
102
102
  * @param {number[]} ids
103
+ * @param {Record<string, string>} parameters
103
104
  * @private
104
105
  */
105
106
  private getSignature;
106
107
  private getError;
108
+ /**
109
+ * Normalize JSON string by converting single quotes to double quotes
110
+ * This allows parsing JSON-like strings with single quotes
111
+ * @param {string} jsonString
112
+ * @returns {string}
113
+ * @private
114
+ */
115
+ private normalizeJsonString;
107
116
  private getFileNameFromMediaType;
108
117
  }
109
118
  export {};
package/dist/storage.js CHANGED
@@ -8,6 +8,8 @@ const qaseIdRegExp = /^@[Qq]-?(\d+)$/;
8
8
  const newQaseIdRegExp = /^@[Qq]ase[Ii][Dd]=(\d+(?:,\s*\d+)*)$/;
9
9
  const qaseTitleRegExp = /^@[Qq]ase[Tt]itle=(.+)$/;
10
10
  const qaseFieldsRegExp = /^@[Qq]ase[Ff]ields=(.+)$/;
11
+ const qaseParametersRegExp = /^@[Qq]ase[Pp]arameters=(.+)$/;
12
+ const qaseGroupParametersRegExp = /^@[Qq]ase[Gg]roup[Pp]arameters=(.+)$/;
11
13
  const qaseIgnoreRegExp = /^@[Qq]ase[Ii][Gg][Nn][Oo][Rr][Ee]$/;
12
14
  class Storage {
13
15
  /**
@@ -213,6 +215,9 @@ class Storage {
213
215
  }
214
216
  }
215
217
  }
218
+ // Merge parameters from tags with parameters from Gherkin examples
219
+ // Parameters from tags take precedence over Gherkin examples
220
+ params = { ...params, ...metadata.parameters };
216
221
  const steps = this.convertSteps(pickle.steps, tc);
217
222
  return {
218
223
  attachments: this.attachments[testCase.testCaseStartedId] ?? [],
@@ -229,10 +234,10 @@ class Storage {
229
234
  message: error?.message ?? null,
230
235
  muted: false,
231
236
  params: params,
232
- group_params: {},
237
+ group_params: metadata.group_params,
233
238
  relations: relations,
234
239
  run_id: null,
235
- signature: this.getSignature(pickle, metadata.ids),
240
+ signature: this.getSignature(pickle, metadata.ids, params),
236
241
  steps: steps,
237
242
  testops_id: metadata.ids.length > 0 ? metadata.ids : null,
238
243
  id: tcs.id,
@@ -309,6 +314,8 @@ class Storage {
309
314
  fields: {},
310
315
  title: null,
311
316
  isIgnore: false,
317
+ parameters: {},
318
+ group_params: {},
312
319
  };
313
320
  for (const tag of tags) {
314
321
  if (qaseIdRegExp.test(tag.name)) {
@@ -327,13 +334,35 @@ class Storage {
327
334
  const value = tag.name.replace(/^@[Qq]ase[Ff]ields=/, '');
328
335
  try {
329
336
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
330
- const record = JSON.parse(value);
337
+ const record = JSON.parse(this.normalizeJsonString(value));
331
338
  metadata.fields = { ...metadata.fields, ...record };
332
339
  }
333
340
  catch (e) {
334
341
  // do nothing
335
342
  }
336
343
  }
344
+ if (qaseParametersRegExp.test(tag.name)) {
345
+ const value = tag.name.replace(/^@[Qq]ase[Pp]arameters=/, '');
346
+ try {
347
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
348
+ const record = JSON.parse(this.normalizeJsonString(value));
349
+ metadata.parameters = { ...metadata.parameters, ...record };
350
+ }
351
+ catch (e) {
352
+ // do nothing
353
+ }
354
+ }
355
+ if (qaseGroupParametersRegExp.test(tag.name)) {
356
+ const value = tag.name.replace(/^@[Qq]ase[Gg]roup[Pp]arameters=/, '');
357
+ try {
358
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
359
+ const record = JSON.parse(this.normalizeJsonString(value));
360
+ metadata.group_params = { ...metadata.group_params, ...record };
361
+ }
362
+ catch (e) {
363
+ // do nothing
364
+ }
365
+ }
337
366
  if (qaseIgnoreRegExp.test(tag.name)) {
338
367
  metadata.isIgnore = true;
339
368
  }
@@ -343,10 +372,11 @@ class Storage {
343
372
  /**
344
373
  * @param {Pickle} pickle
345
374
  * @param {number[]} ids
375
+ * @param {Record<string, string>} parameters
346
376
  * @private
347
377
  */
348
- getSignature(pickle, ids) {
349
- return (0, qase_javascript_commons_1.generateSignature)(ids, [...pickle.uri.split('/'), pickle.name], {});
378
+ getSignature(pickle, ids, parameters = {}) {
379
+ return (0, qase_javascript_commons_1.generateSignature)(ids, [...pickle.uri.split('/'), pickle.name], parameters);
350
380
  }
351
381
  getError(testCaseId) {
352
382
  const testErrors = this.testCaseStartedErrors[testCaseId];
@@ -360,6 +390,22 @@ class Storage {
360
390
  });
361
391
  return error;
362
392
  }
393
+ /**
394
+ * Normalize JSON string by converting single quotes to double quotes
395
+ * This allows parsing JSON-like strings with single quotes
396
+ * @param {string} jsonString
397
+ * @returns {string}
398
+ * @private
399
+ */
400
+ normalizeJsonString(jsonString) {
401
+ // If the string contains single quotes, convert them to double quotes
402
+ // This handles cases like {'key':'value'} which should be {"key":"value"}
403
+ if (jsonString.includes("'")) {
404
+ return jsonString.replace(/'/g, '"');
405
+ }
406
+ // If no single quotes, return as-is (already valid JSON or will fail with proper error)
407
+ return jsonString;
408
+ }
363
409
  getFileNameFromMediaType(mediaType) {
364
410
  const extensions = {
365
411
  'text/plain': 'txt',
package/docs/usage.md CHANGED
@@ -8,7 +8,7 @@ fields, suites, comments, and file attachments to your test cases.
8
8
  ## Adding QaseID to a Test
9
9
 
10
10
  To associate a QaseID with a test in Cucumber.js, use the `@QaseId` tag in your Gherkin feature files. This tag accepts
11
- a single integer or multiple integers separated by commas representing the test's ID(s) in Qase.
11
+ a single integer or multiple integers separated by commas representing the test"s ID(s) in Qase.
12
12
 
13
13
  ### Example
14
14
 
@@ -33,7 +33,7 @@ Feature: User Authentication
33
33
  ## Adding a Title to a Test
34
34
 
35
35
  You can provide a custom title for your test using the `@Title` tag. The tag accepts a string, which will be used as
36
- the test's title in Qase. If no title is provided, the scenario name will be used by default.
36
+ the test"s title in Qase. If no title is provided, the scenario name will be used by default.
37
37
 
38
38
  ### Example
39
39
 
@@ -70,7 +70,7 @@ enhance test case information in Qase.
70
70
  Feature: User Authentication
71
71
 
72
72
  @QaseId=1
73
- @QaseFields={'severity':'high','priority':'medium','description':'Login functionality test'}
73
+ @QaseFields={"severity":"high","priority":"medium","description":"Login functionality test"}
74
74
  Scenario: Successful login
75
75
  Given I am on the login page
76
76
  When I enter valid credentials
@@ -136,7 +136,7 @@ parameter names and values.
136
136
  Feature: User Authentication
137
137
 
138
138
  @QaseId=1
139
- @QaseParameters={'browser':'chrome','environment':'staging'}
139
+ @QaseParameters={"browser":"chrome","environment":"staging"}
140
140
  Scenario: Successful login
141
141
  Given I am on the login page
142
142
  When I enter valid credentials
@@ -156,8 +156,8 @@ group parameter names and values.
156
156
  Feature: User Authentication
157
157
 
158
158
  @QaseId=1
159
- @QaseParameters={'browser':'chrome','environment':'staging'}
160
- @QaseGroupParameters={'test_group':'authentication','test_type':'smoke'}
159
+ @QaseParameters={"browser":"chrome","environment":"staging"}
160
+ @QaseGroupParameters={"test_group":"authentication","test_type":"smoke"}
161
161
  Scenario: Successful login
162
162
  Given I am on the login page
163
163
  When I enter valid credentials
@@ -185,23 +185,23 @@ Feature: User Authentication
185
185
 
186
186
  ```javascript
187
187
  // step_definitions/login_steps.js
188
- const { Given, When, Then } = require('@cucumber/cucumber');
188
+ const { Given, When, Then } = require("@cucumber/cucumber");
189
189
 
190
- Given('I am on the login page', async function() {
190
+ Given("I am on the login page", async function() {
191
191
  // Step implementation
192
- await this.page.goto('https://example.com/login');
192
+ await this.page.goto("https://example.com/login");
193
193
  });
194
194
 
195
- When('I enter valid credentials', async function() {
195
+ When("I enter valid credentials", async function() {
196
196
  // Step implementation
197
- await this.page.fill('#username', 'testuser');
198
- await this.page.fill('#password', 'password');
199
- await this.page.click('#login-button');
197
+ await this.page.fill("#username", "testuser");
198
+ await this.page.fill("#password", "password");
199
+ await this.page.click("#login-button");
200
200
  });
201
201
 
202
- Then('I should be logged in', async function() {
202
+ Then("I should be logged in", async function() {
203
203
  // Step implementation
204
- await this.page.waitForSelector('.dashboard');
204
+ await this.page.waitForSelector(".dashboard");
205
205
  });
206
206
  ```
207
207
 
@@ -216,32 +216,32 @@ attaching files with content, paths, or media types.
216
216
 
217
217
  ```javascript
218
218
  // step_definitions/login_steps.js
219
- const { Given, When, Then } = require('@cucumber/cucumber');
219
+ const { Given, When, Then } = require("@cucumber/cucumber");
220
220
 
221
- Given('I am on the login page', async function() {
222
- await this.page.goto('https://example.com/login');
221
+ Given("I am on the login page", async function() {
222
+ await this.page.goto("https://example.com/login");
223
223
 
224
224
  // Attach screenshot
225
225
  const screenshot = await this.page.screenshot();
226
- await this.attach(screenshot, 'image/png');
226
+ await this.attach(screenshot, "image/png");
227
227
  });
228
228
 
229
- When('I enter valid credentials', async function() {
230
- await this.page.fill('#username', 'testuser');
231
- await this.page.fill('#password', 'password');
229
+ When("I enter valid credentials", async function() {
230
+ await this.page.fill("#username", "testuser");
231
+ await this.page.fill("#password", "password");
232
232
 
233
233
  // Attach text content
234
- await this.attach('Credentials entered successfully', 'text/plain');
234
+ await this.attach("Credentials entered successfully", "text/plain");
235
235
 
236
- await this.page.click('#login-button');
236
+ await this.page.click("#login-button");
237
237
  });
238
238
 
239
- Then('I should be logged in', async function() {
240
- await this.page.waitForSelector('.dashboard');
239
+ Then("I should be logged in", async function() {
240
+ await this.page.waitForSelector(".dashboard");
241
241
 
242
242
  // Attach JSON data
243
- const userData = { username: 'testuser', status: 'logged_in' };
244
- await this.attach(JSON.stringify(userData, null, 2), 'application/json');
243
+ const userData = { username: "testuser", status: "logged_in" };
244
+ await this.attach(JSON.stringify(userData, null, 2), "application/json");
245
245
  });
246
246
  ```
247
247
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cucumberjs-qase-reporter",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "Qase TMS CucumberJS Reporter",
5
5
  "homepage": "https://github.com/qase-tms/qase-javascript",
6
6
  "main": "./dist/index.js",
@@ -40,16 +40,16 @@
40
40
  "license": "Apache-2.0",
41
41
  "dependencies": {
42
42
  "@cucumber/messages": "^22.0.0",
43
- "qase-javascript-commons": "~2.4.8"
43
+ "qase-javascript-commons": "~2.4.16"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@cucumber/cucumber": ">=7.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@jest/globals": "^29.5.0",
50
- "@types/jest": "^29.5.2",
51
- "jest": "^29.5.0",
52
- "ts-jest": "^29.1.0",
53
- "uuid": "^9.0.0"
49
+ "@jest/globals": "^29.7.0",
50
+ "@types/jest": "^29.5.14",
51
+ "jest": "^29.7.0",
52
+ "ts-jest": "^29.4.5",
53
+ "uuid": "^9.0.1"
54
54
  }
55
55
  }
@@ -2,7 +2,9 @@
2
2
  "extends": "./tsconfig.json",
3
3
 
4
4
  "compilerOptions": {
5
- "noEmit": false
5
+ "noEmit": false,
6
+ "skipLibCheck": true,
7
+ "types": []
6
8
  },
7
9
 
8
10
  "include": ["./src/**/*.ts"]