Skip to content

Commit 61351a4

Browse files
committed
chore: bump version to 2.1.8 and enhance QaseParameters support
- Updated package version from 2.1.7 to 2.1.8 in package.json. - Improved support for QaseParameters and QaseGroupParameters tags in the storage logic. - Added normalization for JSON strings to handle single quotes in parameters. - Updated changelog to reflect the new version and features. These changes enhance the functionality of the reporter by allowing more flexible parameter definitions in test tags.
1 parent fdb86b4 commit 61351a4

File tree

5 files changed

+75
-32
lines changed

5 files changed

+75
-32
lines changed

qase-cucumberjs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2+
3+
## What's new
4+
5+
- Improved support for QaseParameters and QaseGroupParameters tags.
6+
17
28

39
## What's new

qase-cucumberjs/docs/usage.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fields, suites, comments, and file attachments to your test cases.
88
## Adding QaseID to a Test
99

1010
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.
1212

1313
### Example
1414

@@ -33,7 +33,7 @@ Feature: User Authentication
3333
## Adding a Title to a Test
3434

3535
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.
3737

3838
### Example
3939

@@ -70,7 +70,7 @@ enhance test case information in Qase.
7070
Feature: User Authentication
7171
7272
@QaseId=1
73-
@QaseFields={'severity':'high','priority':'medium','description':'Login functionality test'}
73+
@QaseFields={"severity":"high","priority":"medium","description":"Login functionality test"}
7474
Scenario: Successful login
7575
Given I am on the login page
7676
When I enter valid credentials
@@ -136,7 +136,7 @@ parameter names and values.
136136
Feature: User Authentication
137137
138138
@QaseId=1
139-
@QaseParameters={'browser':'chrome','environment':'staging'}
139+
@QaseParameters={"browser":"chrome","environment":"staging"}
140140
Scenario: Successful login
141141
Given I am on the login page
142142
When I enter valid credentials
@@ -156,8 +156,8 @@ group parameter names and values.
156156
Feature: User Authentication
157157
158158
@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"}
161161
Scenario: Successful login
162162
Given I am on the login page
163163
When I enter valid credentials
@@ -185,23 +185,23 @@ Feature: User Authentication
185185

186186
```javascript
187187
// step_definitions/login_steps.js
188-
const { Given, When, Then } = require('@cucumber/cucumber');
188+
const { Given, When, Then } = require("@cucumber/cucumber");
189189

190-
Given('I am on the login page', async function() {
190+
Given("I am on the login page", async function() {
191191
// Step implementation
192-
await this.page.goto('https://example.com/login');
192+
await this.page.goto("https://example.com/login");
193193
});
194194

195-
When('I enter valid credentials', async function() {
195+
When("I enter valid credentials", async function() {
196196
// 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");
200200
});
201201

202-
Then('I should be logged in', async function() {
202+
Then("I should be logged in", async function() {
203203
// Step implementation
204-
await this.page.waitForSelector('.dashboard');
204+
await this.page.waitForSelector(".dashboard");
205205
});
206206
```
207207

@@ -216,32 +216,32 @@ attaching files with content, paths, or media types.
216216

217217
```javascript
218218
// step_definitions/login_steps.js
219-
const { Given, When, Then } = require('@cucumber/cucumber');
219+
const { Given, When, Then } = require("@cucumber/cucumber");
220220

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");
223223

224224
// Attach screenshot
225225
const screenshot = await this.page.screenshot();
226-
await this.attach(screenshot, 'image/png');
226+
await this.attach(screenshot, "image/png");
227227
});
228228

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");
232232

233233
// Attach text content
234-
await this.attach('Credentials entered successfully', 'text/plain');
234+
await this.attach("Credentials entered successfully", "text/plain");
235235

236-
await this.page.click('#login-button');
236+
await this.page.click("#login-button");
237237
});
238238

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");
241241

242242
// 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");
245245
});
246246
```
247247

qase-cucumberjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cucumberjs-qase-reporter",
3-
"version": "2.1.7",
3+
"version": "2.1.8",
44
"description": "Qase TMS CucumberJS Reporter",
55
"homepage": "https://github.com/qase-tms/qase-javascript",
66
"main": "./dist/index.js",

qase-cucumberjs/src/storage.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export class Storage {
416416
const value = tag.name.replace(/^@[Qq]ase[Ff]ields=/, '');
417417
try {
418418
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
419-
const record: Record<string, string> = JSON.parse(value);
419+
const record: Record<string, string> = JSON.parse(this.normalizeJsonString(value));
420420
metadata.fields = { ...metadata.fields, ...record };
421421
} catch (e) {
422422
// do nothing
@@ -427,7 +427,7 @@ export class Storage {
427427
const value = tag.name.replace(/^@[Qq]ase[Pp]arameters=/, '');
428428
try {
429429
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
430-
const record: Record<string, string> = JSON.parse(value);
430+
const record: Record<string, string> = JSON.parse(this.normalizeJsonString(value));
431431
metadata.parameters = { ...metadata.parameters, ...record };
432432
} catch (e) {
433433
// do nothing
@@ -438,7 +438,7 @@ export class Storage {
438438
const value = tag.name.replace(/^@[Qq]ase[Gg]roup[Pp]arameters=/, '');
439439
try {
440440
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
441-
const record: Record<string, string> = JSON.parse(value);
441+
const record: Record<string, string> = JSON.parse(this.normalizeJsonString(value));
442442
metadata.group_params = { ...metadata.group_params, ...record };
443443
} catch (e) {
444444
// do nothing
@@ -479,6 +479,23 @@ export class Storage {
479479
return error;
480480
}
481481

482+
/**
483+
* Normalize JSON string by converting single quotes to double quotes
484+
* This allows parsing JSON-like strings with single quotes
485+
* @param {string} jsonString
486+
* @returns {string}
487+
* @private
488+
*/
489+
private normalizeJsonString(jsonString: string): string {
490+
// If the string contains single quotes, convert them to double quotes
491+
// This handles cases like {'key':'value'} which should be {"key":"value"}
492+
if (jsonString.includes("'")) {
493+
return jsonString.replace(/'/g, '"');
494+
}
495+
// If no single quotes, return as-is (already valid JSON or will fail with proper error)
496+
return jsonString;
497+
}
498+
482499
private getFileNameFromMediaType(mediaType: string): string {
483500
const extensions: Record<string, string> = {
484501
'text/plain': 'txt',

qase-cucumberjs/test/storage.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,26 @@ describe('Storage', () => {
581581
expect(result.group_params).toEqual({ test_group: 'authentication', test_type: 'smoke' });
582582
});
583583

584+
it('should parse QaseParameters tag with single quotes', () => {
585+
const tags = [
586+
{ name: "@QaseParameters={'browser':'chrome','environment':'staging'}" },
587+
];
588+
589+
const result = (storage as any).parseTags(tags);
590+
591+
expect(result.parameters).toEqual({ browser: 'chrome', environment: 'staging' });
592+
});
593+
594+
it('should parse QaseGroupParameters tag with single quotes', () => {
595+
const tags = [
596+
{ name: "@QaseGroupParameters={'group':'regression'}" },
597+
];
598+
599+
const result = (storage as any).parseTags(tags);
600+
601+
expect(result.group_params).toEqual({ group: 'regression' });
602+
});
603+
584604
it('should parse both QaseParameters and QaseGroupParameters', () => {
585605
const tags = [
586606
{ name: '@QaseParameters={"browser":"chrome"}' },

0 commit comments

Comments
 (0)