playwright-qase-reporter 2.1.0 → 2.1.1
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 +16 -0
- package/dist/reporter.d.ts +6 -0
- package/dist/reporter.js +18 -1
- package/docs/usage.md +124 -72
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# playwright-qase-reporter@2.1.1
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
Support specifying the test case suite in the `annotation`.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
test('test',
|
|
9
|
+
{
|
|
10
|
+
annotation: { type: 'QaseSuite', description: 'My suite' },
|
|
11
|
+
},
|
|
12
|
+
async ({ page }) => {
|
|
13
|
+
await page.goto('https://example.com');
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
1
17
|
# playwright-qase-reporter@2.1.0
|
|
2
18
|
|
|
3
19
|
## What's new
|
package/dist/reporter.d.ts
CHANGED
|
@@ -103,6 +103,12 @@ export declare class PlaywrightQaseReporter implements Reporter {
|
|
|
103
103
|
* @private
|
|
104
104
|
*/
|
|
105
105
|
private extractQaseIdsFromAnnotation;
|
|
106
|
+
/**
|
|
107
|
+
* @param annotation
|
|
108
|
+
* @returns {string[]}
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
private extractSuiteFromAnnotation;
|
|
106
112
|
/**
|
|
107
113
|
* @param {TestStep[]} steps
|
|
108
114
|
* @returns {boolean}
|
package/dist/reporter.js
CHANGED
|
@@ -282,7 +282,10 @@ class PlaywrightQaseReporter {
|
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
284
|
const error = result.error ? PlaywrightQaseReporter.transformError(result.errors) : null;
|
|
285
|
-
const
|
|
285
|
+
const extractedSuites = this.extractSuiteFromAnnotation(test.annotations);
|
|
286
|
+
const suites = extractedSuites.length > 0
|
|
287
|
+
? extractedSuites
|
|
288
|
+
: (testCaseMetadata.suite ? [testCaseMetadata.suite] : PlaywrightQaseReporter.transformSuiteTitle(test));
|
|
286
289
|
let message = null;
|
|
287
290
|
if (testCaseMetadata.comment !== '') {
|
|
288
291
|
message = testCaseMetadata.comment;
|
|
@@ -433,6 +436,20 @@ class PlaywrightQaseReporter {
|
|
|
433
436
|
}
|
|
434
437
|
return ids;
|
|
435
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* @param annotation
|
|
441
|
+
* @returns {string[]}
|
|
442
|
+
* @private
|
|
443
|
+
*/
|
|
444
|
+
extractSuiteFromAnnotation(annotation) {
|
|
445
|
+
const suites = [];
|
|
446
|
+
for (const item of annotation) {
|
|
447
|
+
if (item.type.toLowerCase() === 'qasesuite' && item.description) {
|
|
448
|
+
suites.push(item.description);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return suites;
|
|
452
|
+
}
|
|
436
453
|
/**
|
|
437
454
|
* @param {TestStep[]} steps
|
|
438
455
|
* @returns {boolean}
|
package/docs/usage.md
CHANGED
|
@@ -13,61 +13,72 @@ Here is the complete list of syntax options available for the reporter:
|
|
|
13
13
|
- [Attach](#attach)
|
|
14
14
|
- [Ignore](#ignore)
|
|
15
15
|
|
|
16
|
-
If you do not use any Qase syntax, the reporter uses the title from the `describe` and `test` functions as the Suite and
|
|
16
|
+
If you do not use any Qase syntax, the reporter uses the title from the `describe` and `test` functions as the Suite and
|
|
17
|
+
Test case title respectively, when publishing results.
|
|
17
18
|
|
|
18
19
|
<br>
|
|
19
20
|
|
|
20
21
|
### Import Statement
|
|
22
|
+
|
|
21
23
|
---
|
|
22
24
|
Add the following statement at the beginning of your spec file, before any tests.
|
|
23
25
|
|
|
24
26
|
```javascript
|
|
25
27
|
import { qase } from 'playwright-qase-reporter';
|
|
26
28
|
```
|
|
29
|
+
|
|
27
30
|
<br>
|
|
28
31
|
|
|
29
32
|
### Example Spec file
|
|
33
|
+
|
|
30
34
|
---
|
|
35
|
+
|
|
31
36
|
```javascript
|
|
32
37
|
import { qase } from 'playwright-qase-reporter';
|
|
33
38
|
|
|
34
39
|
describe('Suite title', () => {
|
|
35
40
|
|
|
36
|
-
test(qase(1, "This is the test name"), () => {
|
|
41
|
+
test(qase(1, "This is the test name"), async () => {
|
|
37
42
|
qase.title("This overrides the test name");
|
|
38
43
|
qase.suite("Suite name");
|
|
39
44
|
qase.fields({ 'severity': 'high', 'priority': 'medium' });
|
|
40
45
|
qase.attach({ paths: './tests/examples/attachments/test-file.txt' });
|
|
41
46
|
qase.comment("A comment for this result");
|
|
42
47
|
qase.ignore(); // doesn't report his result to Qase.
|
|
43
|
-
qase.parameters({ Username: "@test" });
|
|
48
|
+
qase.parameters({ Username: "@test" });
|
|
44
49
|
qase.groupParameters({ Username: username, Password: "123" });
|
|
45
|
-
await test.step('Test step title', async () =>
|
|
50
|
+
await test.step('Test step title', async () => {
|
|
51
|
+
// step logic
|
|
52
|
+
});
|
|
46
53
|
});
|
|
47
|
-
|
|
54
|
+
});
|
|
48
55
|
```
|
|
56
|
+
|
|
49
57
|
<br>
|
|
50
58
|
|
|
51
59
|
### Qase ID
|
|
60
|
+
|
|
52
61
|
---
|
|
53
62
|
|
|
54
|
-
Qase IDs can be defined using two different methods. It is best to select one method and consistently use it throughout
|
|
63
|
+
Qase IDs can be defined using two different methods. It is best to select one method and consistently use it throughout
|
|
64
|
+
your tests. The first method is recommended.
|
|
55
65
|
|
|
56
|
-
Only one Qase Id can be linked to a test.
|
|
66
|
+
Only one Qase Id can be linked to a test.
|
|
57
67
|
|
|
58
|
-
**Inline with the `test` Function**:
|
|
68
|
+
**Inline with the `test` Function**:
|
|
59
69
|
|
|
60
70
|
```javascript
|
|
61
71
|
test(qase(1, 'A simple test'), () => {
|
|
62
|
-
|
|
72
|
+
// Test logic here
|
|
73
|
+
});
|
|
63
74
|
```
|
|
64
75
|
|
|
65
|
-
**Inside the `test` Body**:
|
|
76
|
+
**Inside the `test` Body**:
|
|
66
77
|
|
|
67
78
|
```javascript
|
|
68
79
|
test('A simple test', () => {
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
qase.id(1);
|
|
81
|
+
// Test logic here
|
|
71
82
|
});
|
|
72
83
|
```
|
|
73
84
|
|
|
@@ -75,19 +86,22 @@ test('A simple test', () => {
|
|
|
75
86
|
|
|
76
87
|
```js
|
|
77
88
|
test('A simple test',
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
},
|
|
89
|
+
{
|
|
90
|
+
annotation: { type: 'QaseID', description: '1' },
|
|
91
|
+
},
|
|
81
92
|
async () => {
|
|
82
93
|
// Test logic here
|
|
83
|
-
});
|
|
94
|
+
});
|
|
84
95
|
```
|
|
96
|
+
|
|
85
97
|
<br>
|
|
86
98
|
|
|
87
99
|
### Qase Title
|
|
88
|
-
---
|
|
89
100
|
|
|
90
|
-
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
The `qase.title()` method is used to set the title of a test case, both when creating a new test case from the result,
|
|
104
|
+
and when updating the title of an existing test case - *if used with `qase.id()`.*
|
|
91
105
|
|
|
92
106
|
```javascript
|
|
93
107
|
test("This won't appear in Qase", () => {
|
|
@@ -96,16 +110,21 @@ test("This won't appear in Qase", () => {
|
|
|
96
110
|
});
|
|
97
111
|
```
|
|
98
112
|
|
|
99
|
-
If you don’t explicitly set a title using this method, the title specified in the `test(..)` function will be used for
|
|
113
|
+
If you don’t explicitly set a title using this method, the title specified in the `test(..)` function will be used for
|
|
114
|
+
creating new test cases. However, if this method is defined, it always takes precedence and overrides the title from the
|
|
115
|
+
`test(..)` function.
|
|
100
116
|
|
|
101
117
|
<br>
|
|
102
118
|
|
|
103
119
|
### Steps
|
|
104
|
-
---
|
|
105
120
|
|
|
106
|
-
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
The reporter uses the title from the `test.step` function as the step title. By providing clear and descriptive step
|
|
124
|
+
names, you make it easier to understand the test’s flow when reviewing the test case.
|
|
107
125
|
|
|
108
|
-
Additionally, these steps get their own result in the Qase Test run, offering a well-organized summary of the test flow.
|
|
126
|
+
Additionally, these steps get their own result in the Qase Test run, offering a well-organized summary of the test flow.
|
|
127
|
+
This helps quickly identify the cause of any failures.
|
|
109
128
|
|
|
110
129
|
```javascript
|
|
111
130
|
test('A Test case with steps, updated from code', async () => {
|
|
@@ -122,7 +141,8 @@ test('A Test case with steps, updated from code', async () => {
|
|
|
122
141
|
});
|
|
123
142
|
```
|
|
124
143
|
|
|
125
|
-
You also can use the `qase.step()` method to set the expected result and data of the step, which will be used in the
|
|
144
|
+
You also can use the `qase.step()` method to set the expected result and data of the step, which will be used in the
|
|
145
|
+
Qase report.
|
|
126
146
|
|
|
127
147
|
```javascript
|
|
128
148
|
test('A Test case with steps, updated from code', async () => {
|
|
@@ -142,53 +162,71 @@ test('A Test case with steps, updated from code', async () => {
|
|
|
142
162
|
<br>
|
|
143
163
|
|
|
144
164
|
### Fields
|
|
165
|
+
|
|
145
166
|
---
|
|
146
167
|
|
|
147
|
-
You can define the `description`, `pre-conditions`, `post-conditions`, and fields such as `severity`, `priority`, and
|
|
168
|
+
You can define the `description`, `pre-conditions`, `post-conditions`, and fields such as `severity`, `priority`, and
|
|
169
|
+
`layer` using this method, which enables you to specify and maintain the context of the case directly within your code.
|
|
148
170
|
|
|
149
171
|
```javascript
|
|
150
172
|
test('Maintain your test meta-data from code', async () => {
|
|
151
173
|
qase.fields({
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
174
|
+
severity: 'high',
|
|
175
|
+
priority: 'medium',
|
|
176
|
+
layer: 'api',
|
|
177
|
+
precondition: 'add your precondition',
|
|
178
|
+
postcondition: 'add your postcondition',
|
|
179
|
+
description: `Code it quick, fix it slow,
|
|
158
180
|
Tech debt grows where shortcuts go,
|
|
159
181
|
Refactor later? Ha! We know.`
|
|
160
|
-
|
|
161
|
-
|
|
182
|
+
})
|
|
183
|
+
// test logic here
|
|
162
184
|
});
|
|
163
185
|
```
|
|
164
186
|
|
|
165
187
|
<br>
|
|
166
188
|
|
|
189
|
+
### Suite
|
|
167
190
|
|
|
168
|
-
### Suite
|
|
169
191
|
---
|
|
170
192
|
|
|
171
|
-
You can use this method to nest the resulting test cases in a particular suite. There's something to note here – suites,
|
|
193
|
+
You can use this method to nest the resulting test cases in a particular suite. There's something to note here – suites,
|
|
194
|
+
unlike test cases, are not identified uniquely by the Reporter. Therefore, when defining an existing suite - the title
|
|
195
|
+
of the suite is used for matching.
|
|
172
196
|
|
|
173
197
|
```js
|
|
174
|
-
test(
|
|
175
|
-
qase.suite(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
198
|
+
test('Test with a defined suite', () => {
|
|
199
|
+
qase.suite('Suite defined with qase.suite()');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
/*
|
|
203
|
+
* Or, nest multiple levels of suites.
|
|
204
|
+
* `\t` is used for dividing each suite name.
|
|
205
|
+
*/
|
|
206
|
+
test('Test with a nested suite', () => {
|
|
207
|
+
qase.suite('Application\tAuthentication\tLogin\tEdge_case');
|
|
183
208
|
// test logic here
|
|
184
209
|
});
|
|
210
|
+
|
|
211
|
+
test('Test with a suite from annotations',
|
|
212
|
+
{
|
|
213
|
+
annotation: {
|
|
214
|
+
type: 'QaseSuite',
|
|
215
|
+
description: 'Suite defined in annotation',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
async () => {
|
|
219
|
+
// Test logic here
|
|
220
|
+
});
|
|
185
221
|
```
|
|
222
|
+
|
|
186
223
|
<br>
|
|
187
224
|
|
|
188
225
|
### Parameters
|
|
189
|
-
---
|
|
190
|
-
Parameters are a great way to make your tests more dynamic, reusable, and data-driven. By defining parameters in this method, you can ensure only one test case with all the parameters is created in your Qase project, avoiding duplication.
|
|
191
226
|
|
|
227
|
+
---
|
|
228
|
+
Parameters are a great way to make your tests more dynamic, reusable, and data-driven. By defining parameters in this
|
|
229
|
+
method, you can ensure only one test case with all the parameters is created in your Qase project, avoiding duplication.
|
|
192
230
|
|
|
193
231
|
```javascript
|
|
194
232
|
const testCases = [
|
|
@@ -197,69 +235,83 @@ const testCases = [
|
|
|
197
235
|
{ browser: "Webkit", username: "@charlie", password: "789" },
|
|
198
236
|
];
|
|
199
237
|
|
|
200
|
-
testCases.forEach(({ browser, username, password,
|
|
238
|
+
testCases.forEach(({ browser, username, password, }) => {
|
|
201
239
|
test(`Test login with ${browser}`, async () => {
|
|
202
240
|
qase.title("Verify if page loads on all browsers");
|
|
203
241
|
|
|
204
242
|
qase.parameters({ Browser: browser }); // Single parameter
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
testCases.forEach(({ username, password }) => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
243
|
+
// test logic
|
|
244
|
+
|
|
245
|
+
testCases.forEach(({ username, password }) => {
|
|
246
|
+
test(`Test login with ${username} using qase.groupParameters`, () => {
|
|
247
|
+
qase.title("Verify if user is able to login with their username.");
|
|
248
|
+
|
|
249
|
+
qase.groupParameters({ // Group parameters
|
|
250
|
+
Username: username,
|
|
251
|
+
Password: password,
|
|
252
|
+
});
|
|
253
|
+
// test logic
|
|
254
|
+
});
|
|
214
255
|
});
|
|
215
|
-
|
|
256
|
+
});
|
|
257
|
+
});
|
|
216
258
|
```
|
|
259
|
+
|
|
217
260
|
<br>
|
|
218
261
|
|
|
219
262
|
### Comment
|
|
263
|
+
|
|
220
264
|
---
|
|
221
|
-
In addition to `test.step()`, this method can be used to provide any additional context to your test, it helps maintiain
|
|
265
|
+
In addition to `test.step()`, this method can be used to provide any additional context to your test, it helps maintiain
|
|
266
|
+
the code by clarifying the expected result of the test.
|
|
222
267
|
|
|
223
268
|
```js
|
|
224
269
|
test("A test case with qase.comment()", () => {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
270
|
+
/*
|
|
271
|
+
* Please note, this comment is added to a Result, not to the Test case.
|
|
272
|
+
*/
|
|
228
273
|
qase.comment("This comment is added to the result");
|
|
229
274
|
// test logic here
|
|
230
275
|
});
|
|
231
276
|
```
|
|
277
|
+
|
|
232
278
|
<br>
|
|
233
279
|
|
|
234
280
|
### Attach
|
|
281
|
+
|
|
235
282
|
---
|
|
236
|
-
This method can help attach one, or more files to the test's result. You can also add the file's contents directly from
|
|
283
|
+
This method can help attach one, or more files to the test's result. You can also add the file's contents directly from
|
|
284
|
+
code. For example:
|
|
237
285
|
|
|
238
286
|
```js
|
|
239
287
|
test('Test result with attachment', async () => {
|
|
240
288
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
289
|
+
// To attach a single file
|
|
290
|
+
qase.attach({
|
|
291
|
+
paths: "./tests/examples/attachments/test-file.txt",
|
|
292
|
+
});
|
|
245
293
|
|
|
246
|
-
|
|
247
|
-
|
|
294
|
+
// Add multiple attachments.
|
|
295
|
+
qase.attach({ paths: ['/path/to/file', '/path/to/another/file'] });
|
|
248
296
|
|
|
249
297
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
298
|
+
// Upload file's contents directly from code.
|
|
299
|
+
qase.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' });
|
|
300
|
+
// test logic here
|
|
253
301
|
});
|
|
254
302
|
```
|
|
303
|
+
|
|
255
304
|
<br>
|
|
256
305
|
|
|
257
306
|
### Ignore
|
|
307
|
+
|
|
258
308
|
---
|
|
259
|
-
If this method is added, the reporter will exclude the test’s result from the report sent to Qase. While the test will
|
|
309
|
+
If this method is added, the reporter will exclude the test’s result from the report sent to Qase. While the test will
|
|
310
|
+
still executed by Playwright, its result will not be considered by the reporter.
|
|
260
311
|
|
|
261
312
|
```js
|
|
262
|
-
test(
|
|
313
|
+
test('This test is executed using Playwright; however, it is NOT reported to Qase', () => {
|
|
263
314
|
qase.ignore();
|
|
264
315
|
// test logic here
|
|
316
|
+
});
|
|
265
317
|
```
|