playwright-qase-reporter 2.1.3 → 2.1.5

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
@@ -176,6 +176,7 @@ Reporter options (\* - required):
176
176
  - `testops.run.complete` - Whether the run should be completed
177
177
  - `framework.browser.addAsParameter` - Whether to add the browser name as a parameter, default - `false`
178
178
  - `framework.browser.parameterName` - The name of the parameter to add the browser name to, default - `browser`
179
+ - `framework.markAsFlaky` - Whether to mark tests as flaky if they passed after retries, default - `false`
179
180
 
180
181
  Example `playwright.config.js` config:
181
182
 
@@ -206,6 +207,7 @@ const config = {
206
207
  addAsParameter: true,
207
208
  parameterName: 'Browser Name',
208
209
  },
210
+ markAsFlaky: true,
209
211
  },
210
212
  },
211
213
  ],
package/changelog.md CHANGED
@@ -1,3 +1,20 @@
1
+ # playwright-qase-reporter@2.1.4
2
+
3
+ ## What's new
4
+
5
+ Support marking tests as flaky if they passed after retries.
6
+
7
+ ```ts
8
+ [
9
+ 'playwright-qase-reporter',
10
+ {
11
+ framework: {
12
+ markAsFlaky: true,
13
+ },
14
+ },
15
+ ],
16
+ ```
17
+
1
18
  # playwright-qase-reporter@2.1.3
2
19
 
3
20
  ## What's new
@@ -26,7 +26,11 @@ exports.configSchema = {
26
26
  nullable: true,
27
27
  },
28
28
  }
29
- }
29
+ },
30
+ markAsFlaky: {
31
+ type: 'boolean',
32
+ nullable: true,
33
+ },
30
34
  }
31
35
  }
32
36
  }
package/dist/options.d.ts CHANGED
@@ -3,4 +3,5 @@ export type ReporterOptionsType = {
3
3
  addAsParameter?: boolean;
4
4
  parameterName?: string;
5
5
  };
6
+ markAsFlaky?: boolean;
6
7
  };
package/dist/reporter.js CHANGED
@@ -311,6 +311,10 @@ class PlaywrightQaseReporter {
311
311
  suites = suites.filter(suite => suite !== browser);
312
312
  }
313
313
  }
314
+ // if markAsFlaky is true and the test passed after retries, mark the test as flaky
315
+ if (this.options.markAsFlaky && result.status === 'passed' && result.retry > 0) {
316
+ testCaseMetadata.fields['is_flaky'] = 'true';
317
+ }
314
318
  const testTitle = this.removeQaseIdsFromTitle(test.title);
315
319
  const testResult = {
316
320
  attachments: testCaseMetadata.attachments,
package/docs/usage.md CHANGED
@@ -1,317 +1,286 @@
1
- # Qase Syntax
1
+ # Qase Integration in Playwright
2
2
 
3
- > [**Click here**](../../examples/playwright/test/) to view Example tests for the following syntax.
3
+ This guide demonstrates how to integrate Qase with Playwright, providing instructions on how to add Qase IDs, titles,
4
+ fields, suites, comments, and file attachments to your test cases.
4
5
 
5
- Here is the complete list of syntax options available for the reporter:
6
- - [Qase Id](#qase-id)
7
- - [Qase Title](#qase-title)
8
- - [Steps](#steps)
9
- - [Fields](#fields)
10
- - [Suite](#suite)
11
- - [Parameters](#parameters)
12
- - [Comment](#comment)
13
- - [Attach](#attach)
14
- - [Ignore](#ignore)
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
17
- Test case title respectively, when publishing results.
6
+ ---
18
7
 
19
- <br>
8
+ ## Adding QaseID to a Test
20
9
 
21
- ### Import Statement
10
+ To associate a QaseID with a test in Playwright, use the `qase` function. This function accepts a single integer
11
+ representing the test's ID in Qase.
22
12
 
23
- ---
24
- Add the following statement at the beginning of your spec file, before any tests.
13
+ ### Example
25
14
 
26
15
  ```javascript
27
16
  import { qase } from 'playwright-qase-reporter';
28
- ```
29
17
 
30
- <br>
18
+ test(qase(1, 'test'), async ({ page }) => {
19
+ await page.goto('https://example.com');
20
+ });
31
21
 
32
- ### Example Spec file
22
+ test(qase([1, 2, 3], 'test'), async ({ page }) => {
23
+ await page.goto('https://example.com');
24
+ });
25
+ ```
33
26
 
34
27
  ---
35
28
 
29
+ ## Adding a Title to a Test
30
+
31
+ You can provide a title for your test using the `qase.title` function. The function accepts a string, which will be
32
+ used as the test's title in Qase. If no title is provided, the test method name will be used by default.
33
+
34
+ ### Example
35
+
36
36
  ```javascript
37
37
  import { qase } from 'playwright-qase-reporter';
38
38
 
39
- describe('Suite title', () => {
40
-
41
- test(qase(1, "This is the test name"), async () => {
42
- qase.title("This overrides the test name");
43
- qase.suite("Suite name");
44
- qase.fields({ 'severity': 'high', 'priority': 'medium' });
45
- qase.attach({ paths: './tests/examples/attachments/test-file.txt' });
46
- qase.comment("A comment for this result");
47
- qase.ignore(); // doesn't report his result to Qase.
48
- qase.parameters({ Username: "@test" });
49
- qase.groupParameters({ Username: username, Password: "123" });
50
- await test.step('Test step title', async () => {
51
- // step logic
52
- });
53
- });
39
+ test('test', async ({ page }) => {
40
+ qase.title('Title');
41
+ await page.goto('https://example.com');
54
42
  });
55
43
  ```
56
44
 
57
- <br>
45
+ ---
58
46
 
59
- ### Qase ID
47
+ ## Adding Fields to a Test
60
48
 
61
- ---
49
+ The `qase.fields` function allows you to add additional metadata to a test case. You can specify multiple fields to
50
+ enhance test case information in Qase.
62
51
 
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.
52
+ ### System Fields
65
53
 
66
- Only one Qase Id can be linked to a test.
54
+ - `description` Description of the test case.
55
+ - `preconditions` — Preconditions for the test case.
56
+ - `postconditions` — Postconditions for the test case.
57
+ - `severity` — Severity of the test case (e.g., `critical`, `major`).
58
+ - `priority` — Priority of the test case (e.g., `high`, `low`).
59
+ - `layer` — Test layer (e.g., `UI`, `API`).
67
60
 
68
- **Inline with the `test` Function**:
61
+ ### Example
69
62
 
70
63
  ```javascript
71
- test(qase(1, 'A simple test'), () => {
72
- // Test logic here
64
+ import { qase } from 'playwright-qase-reporter';
65
+
66
+ test('test', async ({ page }) => {
67
+ qase.fields({ description: "Description", preconditions: "Preconditions" });
68
+ await page.goto('https://example.com');
73
69
  });
74
70
  ```
75
71
 
76
- **Inside the `test` Body**:
72
+ ---
73
+
74
+ ## Adding a Suite to a Test
75
+
76
+ To assign a suite or sub-suite to a test, use the `qase.suite` function. It can receive a suite name, and optionally a
77
+ sub-suite, both as strings.
78
+
79
+ ### Example
77
80
 
78
81
  ```javascript
79
- test('A simple test', () => {
80
- qase.id(1);
81
- // Test logic here
82
- });
83
- ```
82
+ import { qase } from 'playwright-qase-reporter';
84
83
 
85
- **In the test's annotations**:
84
+ test('test', async ({ page }) => {
85
+ qase.suite("Suite 01");
86
+ await page.goto('https://example.com');
87
+ });
86
88
 
87
- ```js
88
- test('A simple test',
89
- {
90
- annotation: { type: 'QaseID', description: '1' },
91
- },
92
- async () => {
93
- // Test logic here
94
- });
89
+ test('test', async ({ page }) => {
90
+ qase.suite("Suite 01\tSuite 02");
91
+ await page.goto('https://example.com');
92
+ });
95
93
  ```
96
94
 
97
- <br>
95
+ ---
98
96
 
99
- ### Qase Title
97
+ ## Ignoring a Test in Qase
100
98
 
101
- ---
99
+ To exclude a test from being reported to Qase (while still executing the test in Playwright), use the `qase.ignore`
100
+ function. The test will run, but its result will not be sent to Qase.
102
101
 
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()`.*
102
+ ### Example
105
103
 
106
104
  ```javascript
107
- test("This won't appear in Qase", () => {
108
- qase.title("This text will be the title of the test, in Qase");
109
- // Test logic here
105
+ import { qase } from 'playwright-qase-reporter';
106
+
107
+ test('test', async ({ page }) => {
108
+ qase.ignore();
109
+ await page.goto('https://example.com');
110
110
  });
111
111
  ```
112
112
 
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.
116
-
117
- <br>
118
-
119
- ### Steps
120
-
121
113
  ---
122
114
 
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.
115
+ ## Adding a Comment to a Test
125
116
 
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.
117
+ You can attach comments to the test results in Qase using the `qase.comment` function. The comment will be displayed
118
+ alongside the test execution details in Qase.
119
+
120
+ ### Example
128
121
 
129
122
  ```javascript
130
- test('A Test case with steps, updated from code', async () => {
131
- await test.step('Initialize the environment', async () => {
132
- // Set up test environment
133
- });
134
- await test.step('Test Core Functionality of the app', async () => {
135
- // Exercise core functionality
136
- });
123
+ import { qase } from 'playwright-qase-reporter';
137
124
 
138
- await test.step('Verify Expected Behavior of the app', async () => {
139
- // Assert expected behavior
140
- });
125
+ test('test', async ({ page }) => {
126
+ qase.comment("Some comment");
127
+ await page.goto('https://example.com');
141
128
  });
142
129
  ```
143
130
 
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.
131
+ ---
132
+
133
+ ## Attaching Files to a Test
134
+
135
+ To attach files to a test result, use the `qase.attach` function. This method supports attaching one or multiple files,
136
+ along with optional file names, comments, and file types.
137
+
138
+ ### Example
146
139
 
147
140
  ```javascript
148
- test('A Test case with steps, updated from code', async () => {
149
- await test.step(qase.step('Initialize the environment'), async () => {
150
- // Set up test environment
151
- });
152
- await test.step(qase.step('Test Core Functionality of the app', 'expected result'), async () => {
153
- // Exercise core functionality
154
- });
141
+ import { qase } from 'playwright-qase-reporter';
155
142
 
156
- await test.step(qase.step('Verify Expected Behavior of the app', 'expected result', 'data'), async () => {
157
- // Assert expected behavior
158
- });
143
+ test('test', async ({ page }) => {
144
+ qase.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' });
145
+ qase.attach({ paths: '/path/to/file' });
146
+ qase.attach({ paths: ['/path/to/file', '/path/to/another/file'] });
147
+ await page.goto('https://example.com');
159
148
  });
160
149
  ```
161
150
 
162
- <br>
163
-
164
- ### Fields
151
+ ## Adding Parameters to a Test
165
152
 
166
- ---
153
+ You can add parameters to a test case using the `qase.parameters` function. This function accepts an object with
154
+ parameter names and values.
167
155
 
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.
156
+ ### Example
170
157
 
171
158
  ```javascript
172
- test('Maintain your test meta-data from code', async () => {
173
- qase.fields({
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,
180
- Tech debt grows where shortcuts go,
181
- Refactor later? Ha! We know.`
182
- })
183
- // test logic here
159
+ import { qase } from 'playwright-qase-reporter';
160
+
161
+ test('test', async ({ page }) => {
162
+ qase.parameters({ param1: 'value1', param2: 'value2' });
163
+ await page.goto('https://example.com');
184
164
  });
185
165
  ```
186
166
 
187
- <br>
188
-
189
- ### Suite
167
+ ## Adding Group Parameters to a Test
190
168
 
191
- ---
169
+ To add group parameters to a test case, use the `qase.groupParameters` function. This function accepts an object with
170
+ group parameter names and values.
192
171
 
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
+ ### Example
196
173
 
197
- ```js
198
- test('Test with a defined suite', () => {
199
- qase.suite('Suite defined with qase.suite()');
200
- });
174
+ ```javascript
175
+ import { qase } from 'playwright-qase-reporter';
201
176
 
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');
208
- // test logic here
177
+ test('test', async ({ page }) => {
178
+ qase.parameters({ param1: 'value1', param2: 'value2' });
179
+ qase.groupParameters({ param3: 'value3', param4: 'value4' });
180
+ await page.goto('https://example.com');
209
181
  });
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
- });
221
182
  ```
222
183
 
223
- <br>
184
+ ## Adding Steps to a Test
224
185
 
225
- ### Parameters
186
+ You can add steps to a test case using the `qase.step` function. This function accepts a string, which will be used as
187
+ the step description in Qase.
226
188
 
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.
189
+ ### Example
230
190
 
231
191
  ```javascript
232
- const testCases = [
233
- { browser: "Chromium", username: "@alice", password: "123" },
234
- { browser: "Firefox", username: "@bob", password: "456" },
235
- { browser: "Webkit", username: "@charlie", password: "789" },
236
- ];
237
-
238
- testCases.forEach(({ browser, username, password, }) => {
239
- test(`Test login with ${browser}`, async () => {
240
- qase.title("Verify if page loads on all browsers");
241
-
242
- qase.parameters({ Browser: browser }); // Single parameter
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
- });
255
- });
192
+ import { qase } from 'playwright-qase-reporter';
193
+
194
+ test('test', async ({ page }) => {
195
+ await test.step(qase.step('Some step'), async () => {
196
+ // some actions
256
197
  });
198
+ await page.goto('https://example.com');
257
199
  });
258
200
  ```
259
201
 
260
- <br>
202
+ ## Annotations
261
203
 
262
- ### Comment
204
+ Playwright Qase reporter supports test annotations for setting Qase IDs, titles, and suites.
263
205
 
264
- ---
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.
267
-
268
- ```js
269
- test("A test case with qase.comment()", () => {
270
- /*
271
- * Please note, this comment is added to a Result, not to the Test case.
272
- */
273
- qase.comment("This comment is added to the result");
274
- // test logic here
275
- });
276
- ```
206
+ ### Example
277
207
 
278
- <br>
208
+ ```javascript
209
+ test('test',
210
+ {
211
+ annotation: { type: 'QaseID', description: '1' },
212
+ },
213
+ async ({ page }) => {
214
+ await page.goto('https://example.com');
215
+ });
279
216
 
280
- ### Attach
217
+ test('test',
218
+ {
219
+ annotation: { type: 'QaseSuite', description: 'Suite defined in annotation' },
220
+ },
221
+ async ({ page }) => {
222
+ await page.goto('https://example.com');
223
+ });
224
+ ```
281
225
 
282
226
  ---
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:
285
227
 
286
- ```js
287
- test('Test result with attachment', async () => {
228
+ ## Selective execution tests
288
229
 
289
- // To attach a single file
290
- qase.attach({
291
- paths: "./tests/examples/attachments/test-file.txt",
292
- });
230
+ You can use the `grep` property to select tests to run. You can specify a regular expression to match the Qase IDs in `playwright.config.js` or in command line arguments.
293
231
 
294
- // Add multiple attachments.
295
- qase.attach({ paths: ['/path/to/file', '/path/to/another/file'] });
232
+ ### Configuration-based filtering
296
233
 
234
+ ```javascript
235
+ const config = {
236
+ grep: /(Qase ID: 1|2|3)/,
237
+ reporter: [
238
+ [
239
+ 'playwright-qase-reporter',
240
+ {
241
+ debug: true,
242
+
243
+ testops: {
244
+ api: {
245
+ token: 'api_key',
246
+ },
247
+
248
+ project: 'project_code',
249
+ uploadAttachments: true,
250
+
251
+ run: {
252
+ complete: true,
253
+ },
254
+ },
255
+ },
256
+ ],
257
+ ],
258
+ };
259
+
260
+ module.exports = config;
261
+ ```
297
262
 
298
- // Upload file's contents directly from code.
299
- qase.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' });
300
- // test logic here
301
- });
263
+ ### Command line filtering
264
+
265
+ ```bash
266
+ # Run tests with specific Qase IDs
267
+ npx playwright test --grep "(Qase ID: 1|2|3)"
302
268
  ```
303
269
 
304
- <br>
270
+ ### Using qasectl for test plan filtering
305
271
 
306
- ### Ignore
272
+ If you use `qase([Id], 'Test name')` syntax for test case IDs, you can use `qasectl` for getting prepared regex with all Qase IDs from your test plan. See [qasectl](https://github.com/qase-tms/qasectl/blob/main/docs/command.md#get-filtered-results) for more information.
307
273
 
308
- ---
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.
274
+ For example, if you have a test plan with ID 123, you can get the regular expression with all Qase IDs from it with the following command:
311
275
 
312
- ```js
313
- test('This test is executed using Playwright; however, it is NOT reported to Qase', () => {
314
- qase.ignore();
315
- // test logic here
316
- });
276
+ ```bash
277
+ qasectl testops filter --project PROJ --token <token> --planID 123 --framework playwright --output qase.env --verbose
317
278
  ```
279
+
280
+ Specify result to run command:
281
+
282
+ ```bash
283
+ npx playwright test --grep "$(cat qase.env | grep QASE_FILTERED_RESULTS | cut -d'=' -f2)"
284
+ ```
285
+
286
+ Only tests with Qase IDs from the file will be run and reported to Qase.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright-qase-reporter",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "Qase TMS Playwright Reporter",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "license": "Apache-2.0",
45
45
  "dependencies": {
46
46
  "chalk": "^4.1.2",
47
- "qase-javascript-commons": "~2.3.3",
47
+ "qase-javascript-commons": "~2.4.1",
48
48
  "uuid": "^9.0.0"
49
49
  },
50
50
  "peerDependencies": {