cucumberjs-qase-reporter 2.1.2 → 2.1.4
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 +2 -0
- package/changelog.md +6 -0
- package/dist/models.d.ts +4 -0
- package/dist/storage.js +34 -9
- package/docs/usage.md +248 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,6 +27,8 @@ from Qase.io before executing tests. It's a more reliable way to bind
|
|
|
27
27
|
autotests to test cases, that persists when you rename, move, or
|
|
28
28
|
parameterize your tests.
|
|
29
29
|
|
|
30
|
+
For more information, see the [Usage Guide](docs/usage.md).
|
|
31
|
+
|
|
30
32
|
For example:
|
|
31
33
|
|
|
32
34
|
```gherkin
|
package/changelog.md
CHANGED
package/dist/models.d.ts
CHANGED
package/dist/storage.js
CHANGED
|
@@ -4,11 +4,11 @@ exports.Storage = void 0;
|
|
|
4
4
|
const qase_javascript_commons_1 = require("qase-javascript-commons");
|
|
5
5
|
const cucumber_1 = require("@cucumber/cucumber");
|
|
6
6
|
const uuid_1 = require("uuid");
|
|
7
|
-
const qaseIdRegExp = /^@[Qq]-?(\d+)
|
|
8
|
-
const newQaseIdRegExp = /^@[Qq]ase[Ii][Dd]=(\d+(?:,\s*\d+)*)
|
|
9
|
-
const qaseTitleRegExp = /^@[Qq]ase[Tt]itle=(.+)
|
|
10
|
-
const qaseFieldsRegExp = /^@[Qq]ase[Ff]ields=(.+)
|
|
11
|
-
const qaseIgnoreRegExp = /^@[Qq]ase[Ii][Gg][Nn][Oo][Rr][Ee]
|
|
7
|
+
const qaseIdRegExp = /^@[Qq]-?(\d+)$/;
|
|
8
|
+
const newQaseIdRegExp = /^@[Qq]ase[Ii][Dd]=(\d+(?:,\s*\d+)*)$/;
|
|
9
|
+
const qaseTitleRegExp = /^@[Qq]ase[Tt]itle=(.+)$/;
|
|
10
|
+
const qaseFieldsRegExp = /^@[Qq]ase[Ff]ields=(.+)$/;
|
|
11
|
+
const qaseIgnoreRegExp = /^@[Qq]ase[Ii][Gg][Nn][Oo][Rr][Ee]$/;
|
|
12
12
|
class Storage {
|
|
13
13
|
/**
|
|
14
14
|
* @type {Record<string, Pickle>}
|
|
@@ -66,7 +66,26 @@ class Storage {
|
|
|
66
66
|
const { children, name } = document.feature;
|
|
67
67
|
children.forEach(({ scenario }) => {
|
|
68
68
|
if (scenario) {
|
|
69
|
-
|
|
69
|
+
const parameters = {};
|
|
70
|
+
scenario.examples?.forEach((example) => {
|
|
71
|
+
if (example.tableHeader && example.tableBody) {
|
|
72
|
+
const columnNames = example.tableHeader.cells.map(cell => cell.value);
|
|
73
|
+
example.tableBody.forEach((row) => {
|
|
74
|
+
const rowParams = {};
|
|
75
|
+
row.cells.forEach((cell, index) => {
|
|
76
|
+
const columnName = columnNames[index];
|
|
77
|
+
if (columnName) {
|
|
78
|
+
rowParams[columnName] = cell.value;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
parameters[row.id] = rowParams;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
this.scenarios[scenario.id] = {
|
|
86
|
+
name: name,
|
|
87
|
+
parameters: parameters,
|
|
88
|
+
};
|
|
70
89
|
}
|
|
71
90
|
});
|
|
72
91
|
}
|
|
@@ -169,18 +188,24 @@ class Storage {
|
|
|
169
188
|
}
|
|
170
189
|
const error = this.getError(tcs.id);
|
|
171
190
|
let relations = null;
|
|
172
|
-
|
|
191
|
+
let params = {};
|
|
192
|
+
const nodeId = pickle.astNodeIds[0];
|
|
173
193
|
if (nodeId != undefined && this.scenarios[nodeId] != undefined) {
|
|
174
194
|
relations = {
|
|
175
195
|
suite: {
|
|
176
196
|
data: [
|
|
177
197
|
{
|
|
178
|
-
title: this.scenarios[nodeId] ?? '',
|
|
198
|
+
title: this.scenarios[nodeId]?.name ?? '',
|
|
179
199
|
public_id: null,
|
|
180
200
|
},
|
|
181
201
|
],
|
|
182
202
|
},
|
|
183
203
|
};
|
|
204
|
+
for (const id of pickle.astNodeIds) {
|
|
205
|
+
if (this.scenarios[nodeId]?.parameters[id] != undefined) {
|
|
206
|
+
params = { ...params, ...this.scenarios[nodeId]?.parameters[id] };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
184
209
|
}
|
|
185
210
|
return {
|
|
186
211
|
attachments: this.attachments[testCase.testCaseStartedId] ?? [],
|
|
@@ -196,7 +221,7 @@ class Storage {
|
|
|
196
221
|
fields: metadata.fields,
|
|
197
222
|
message: error?.message ?? null,
|
|
198
223
|
muted: false,
|
|
199
|
-
params:
|
|
224
|
+
params: params,
|
|
200
225
|
group_params: {},
|
|
201
226
|
relations: relations,
|
|
202
227
|
run_id: null,
|
package/docs/usage.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Qase Integration in Cucumber.js
|
|
2
|
+
|
|
3
|
+
This guide demonstrates how to integrate Qase with Cucumber.js, providing instructions on how to add Qase IDs, titles,
|
|
4
|
+
fields, suites, comments, and file attachments to your test cases.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Adding QaseID to a Test
|
|
9
|
+
|
|
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.
|
|
12
|
+
|
|
13
|
+
### Example
|
|
14
|
+
|
|
15
|
+
```gherkin
|
|
16
|
+
Feature: User Authentication
|
|
17
|
+
|
|
18
|
+
@QaseId=1
|
|
19
|
+
Scenario: Successful login
|
|
20
|
+
Given I am on the login page
|
|
21
|
+
When I enter valid credentials
|
|
22
|
+
Then I should be logged in
|
|
23
|
+
|
|
24
|
+
@QaseId=2,3,4
|
|
25
|
+
Scenario: Multiple test cases
|
|
26
|
+
Given I am on the login page
|
|
27
|
+
When I enter invalid credentials
|
|
28
|
+
Then I should see an error message
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Adding a Title to a Test
|
|
34
|
+
|
|
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.
|
|
37
|
+
|
|
38
|
+
### Example
|
|
39
|
+
|
|
40
|
+
```gherkin
|
|
41
|
+
Feature: User Authentication
|
|
42
|
+
|
|
43
|
+
@QaseId=1
|
|
44
|
+
@Title=Custom Test Title
|
|
45
|
+
Scenario: Successful login
|
|
46
|
+
Given I am on the login page
|
|
47
|
+
When I enter valid credentials
|
|
48
|
+
Then I should be logged in
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Adding Fields to a Test
|
|
54
|
+
|
|
55
|
+
The `@QaseFields` tag allows you to add additional metadata to a test case. You can specify multiple fields to
|
|
56
|
+
enhance test case information in Qase.
|
|
57
|
+
|
|
58
|
+
### System Fields
|
|
59
|
+
|
|
60
|
+
- `description` — Description of the test case.
|
|
61
|
+
- `preconditions` — Preconditions for the test case.
|
|
62
|
+
- `postconditions` — Postconditions for the test case.
|
|
63
|
+
- `severity` — Severity of the test case (e.g., `critical`, `major`).
|
|
64
|
+
- `priority` — Priority of the test case (e.g., `high`, `low`).
|
|
65
|
+
- `layer` — Test layer (e.g., `UI`, `API`).
|
|
66
|
+
|
|
67
|
+
### Example
|
|
68
|
+
|
|
69
|
+
```gherkin
|
|
70
|
+
Feature: User Authentication
|
|
71
|
+
|
|
72
|
+
@QaseId=1
|
|
73
|
+
@QaseFields={'severity':'high','priority':'medium','description':'Login functionality test'}
|
|
74
|
+
Scenario: Successful login
|
|
75
|
+
Given I am on the login page
|
|
76
|
+
When I enter valid credentials
|
|
77
|
+
Then I should be logged in
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Adding a Suite to a Test
|
|
83
|
+
|
|
84
|
+
To assign a suite or sub-suite to a test, use the `@QaseSuite` tag. It can receive a suite name, and optionally a
|
|
85
|
+
sub-suite, both as strings.
|
|
86
|
+
|
|
87
|
+
### Example
|
|
88
|
+
|
|
89
|
+
```gherkin
|
|
90
|
+
Feature: User Authentication
|
|
91
|
+
|
|
92
|
+
@QaseId=1
|
|
93
|
+
@QaseSuite=Authentication
|
|
94
|
+
Scenario: Successful login
|
|
95
|
+
Given I am on the login page
|
|
96
|
+
When I enter valid credentials
|
|
97
|
+
Then I should be logged in
|
|
98
|
+
|
|
99
|
+
@QaseId=2
|
|
100
|
+
@QaseSuite=Authentication\tLogin\tEdge Cases
|
|
101
|
+
Scenario: Login with special characters
|
|
102
|
+
Given I am on the login page
|
|
103
|
+
When I enter credentials with special characters
|
|
104
|
+
Then I should be logged in
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Ignoring a Test in Qase
|
|
110
|
+
|
|
111
|
+
To exclude a test from being reported to Qase (while still executing the test in Cucumber.js), use the `@QaseIgnore`
|
|
112
|
+
tag. The test will run, but its result will not be sent to Qase.
|
|
113
|
+
|
|
114
|
+
### Example
|
|
115
|
+
|
|
116
|
+
```gherkin
|
|
117
|
+
Feature: User Authentication
|
|
118
|
+
|
|
119
|
+
@QaseIgnore
|
|
120
|
+
Scenario: This test will not be reported to Qase
|
|
121
|
+
Given I am on the login page
|
|
122
|
+
When I enter valid credentials
|
|
123
|
+
Then I should be logged in
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Adding Parameters to a Test
|
|
129
|
+
|
|
130
|
+
You can add parameters to a test case using the `@QaseParameters` tag. This tag accepts a JSON object with
|
|
131
|
+
parameter names and values.
|
|
132
|
+
|
|
133
|
+
### Example
|
|
134
|
+
|
|
135
|
+
```gherkin
|
|
136
|
+
Feature: User Authentication
|
|
137
|
+
|
|
138
|
+
@QaseId=1
|
|
139
|
+
@QaseParameters={'browser':'chrome','environment':'staging'}
|
|
140
|
+
Scenario: Successful login
|
|
141
|
+
Given I am on the login page
|
|
142
|
+
When I enter valid credentials
|
|
143
|
+
Then I should be logged in
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Adding Group Parameters to a Test
|
|
149
|
+
|
|
150
|
+
To add group parameters to a test case, use the `@QaseGroupParameters` tag. This tag accepts a JSON object with
|
|
151
|
+
group parameter names and values.
|
|
152
|
+
|
|
153
|
+
### Example
|
|
154
|
+
|
|
155
|
+
```gherkin
|
|
156
|
+
Feature: User Authentication
|
|
157
|
+
|
|
158
|
+
@QaseId=1
|
|
159
|
+
@QaseParameters={'browser':'chrome','environment':'staging'}
|
|
160
|
+
@QaseGroupParameters={'test_group':'authentication','test_type':'smoke'}
|
|
161
|
+
Scenario: Successful login
|
|
162
|
+
Given I am on the login page
|
|
163
|
+
When I enter valid credentials
|
|
164
|
+
Then I should be logged in
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Adding Steps to a Test
|
|
170
|
+
|
|
171
|
+
Cucumber.js automatically creates steps from your Gherkin scenarios. Each `Given`, `When`, and `Then` statement
|
|
172
|
+
becomes a step in Qase. You can also add custom step information in your step definitions.
|
|
173
|
+
|
|
174
|
+
### Example
|
|
175
|
+
|
|
176
|
+
```gherkin
|
|
177
|
+
Feature: User Authentication
|
|
178
|
+
|
|
179
|
+
@QaseId=1
|
|
180
|
+
Scenario: Successful login
|
|
181
|
+
Given I am on the login page
|
|
182
|
+
When I enter valid credentials
|
|
183
|
+
Then I should be logged in
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
// step_definitions/login_steps.js
|
|
188
|
+
const { Given, When, Then } = require('@cucumber/cucumber');
|
|
189
|
+
|
|
190
|
+
Given('I am on the login page', async function() {
|
|
191
|
+
// Step implementation
|
|
192
|
+
await this.page.goto('https://example.com/login');
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
When('I enter valid credentials', async function() {
|
|
196
|
+
// Step implementation
|
|
197
|
+
await this.page.fill('#username', 'testuser');
|
|
198
|
+
await this.page.fill('#password', 'password');
|
|
199
|
+
await this.page.click('#login-button');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
Then('I should be logged in', async function() {
|
|
203
|
+
// Step implementation
|
|
204
|
+
await this.page.waitForSelector('.dashboard');
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Attaching Files to a Test
|
|
211
|
+
|
|
212
|
+
You can attach files to test results using the `this.attach()` method in your step definitions. This method supports
|
|
213
|
+
attaching files with content, paths, or media types.
|
|
214
|
+
|
|
215
|
+
### Example
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
// step_definitions/login_steps.js
|
|
219
|
+
const { Given, When, Then } = require('@cucumber/cucumber');
|
|
220
|
+
|
|
221
|
+
Given('I am on the login page', async function() {
|
|
222
|
+
await this.page.goto('https://example.com/login');
|
|
223
|
+
|
|
224
|
+
// Attach screenshot
|
|
225
|
+
const screenshot = await this.page.screenshot();
|
|
226
|
+
await this.attach(screenshot, 'image/png');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
When('I enter valid credentials', async function() {
|
|
230
|
+
await this.page.fill('#username', 'testuser');
|
|
231
|
+
await this.page.fill('#password', 'password');
|
|
232
|
+
|
|
233
|
+
// Attach text content
|
|
234
|
+
await this.attach('Credentials entered successfully', 'text/plain');
|
|
235
|
+
|
|
236
|
+
await this.page.click('#login-button');
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
Then('I should be logged in', async function() {
|
|
240
|
+
await this.page.waitForSelector('.dashboard');
|
|
241
|
+
|
|
242
|
+
// Attach JSON data
|
|
243
|
+
const userData = { username: 'testuser', status: 'logged_in' };
|
|
244
|
+
await this.attach(JSON.stringify(userData, null, 2), 'application/json');
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cucumberjs-qase-reporter",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
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.
|
|
43
|
+
"qase-javascript-commons": "~2.4.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@cucumber/cucumber": ">=7.0.0"
|