allure-playwright 3.0.0-beta.1 → 3.0.0-beta.11

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
@@ -5,22 +5,10 @@
5
5
  [<img src="https://allurereport.org/public/img/allure-report.svg" height="85px" alt="Allure Report logo" align="right" />](https://allurereport.org "Allure Report")
6
6
 
7
7
  - Learn more about Allure Report at https://allurereport.org
8
- - 📚 [Documentation](https://allurereport.org/docs/) – discover official documentation for Allure
9
- Report
10
- -
11
-
12
- ❓ [Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) –
13
- get help from the team and community
14
-
15
- -
16
-
17
- 📢 [Official annoucements](https://github.com/orgs/allure-framework/discussions/categories/announcements) –
18
- be in touch with the latest updates
19
-
20
- -
21
-
22
- 💬 [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) –
23
- engage in casual conversations, share insights and ideas with the community
8
+ - 📚 [Documentation](https://allurereport.org/docs/) – discover official documentation for Allure Report
9
+ - ❓ [Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) – get help from the team and community
10
+ - 📢 [Official annoucements](https://github.com/orgs/allure-framework/discussions/categories/announcements) – be in touch with the latest updates
11
+ - 💬 [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) – engage in casual conversations, share insights and ideas with the community
24
12
 
25
13
  ---
26
14
 
@@ -34,408 +22,109 @@ npm i -D allure-playwright
34
22
 
35
23
  ## Usage
36
24
 
37
- Just add `allure-playwright` into Playwright configuration file:
25
+ Add `allure-playwright` as the reporter in the Playwright configuration file:
38
26
 
39
27
  ```js
40
- module.exports = {
28
+ import { defineConfig } from '@playwright/test';
29
+
30
+ export default defineConfig({
41
31
  reporter: "allure-playwright",
42
- }
32
+ });
43
33
  ```
44
34
 
45
- Or use the reporter with another ones:
35
+ Or, if you want to use more than one reporter:
46
36
 
47
37
  ```js
48
- module.exports = {
49
- reporter: [["line"], ["allure-playwright"]];
50
- }
38
+ import { defineConfig } from '@playwright/test';
39
+
40
+ export default defineConfig({
41
+ reporter: [["line"], ["allure-playwright"]],
42
+ });
51
43
  ```
52
44
 
53
- Or pass the same value via command line:
45
+ Or pass the same values via the command line:
54
46
 
55
47
  ```bash
56
48
  npx playwright test --reporter=line,allure-playwright
57
49
  ```
58
50
 
59
- Specify location for allure results:
51
+ When the test run completes, the result files will be generated in the `./allure-results`
52
+ directory. If you want to use another location, provide it via the `resultsDir`
53
+ reporter option ([see below](#allure-playwright-options)).
60
54
 
61
- Mac / Linux
55
+ ### View the report
62
56
 
63
- ```bash
64
- ALLURE_RESULTS_DIR=my-allure-results npx playwright test --reporter=line,allure-playwright
65
- ```
66
-
67
- Windows
68
-
69
- ```bash
70
- set ALLURE_RESULTS_DIR=my-allure-results
71
- npx playwright test --reporter=line,allure-playwright
72
- ```
57
+ > [!NOTE]
58
+ > You need Allure Report to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) for more details.
73
59
 
74
60
  Generate Allure Report:
75
61
 
76
62
  ```bash
77
- allure generate my-allure-results -o allure-report --clean
63
+ allure generate ./allure-results -o ./allure-report
78
64
  ```
79
65
 
80
66
  Open Allure Report:
81
67
 
82
68
  ```bash
83
- allure open allure-report
84
- ```
85
-
86
- ## Reporter options
87
-
88
- Some reporter settings can set by following options:
89
-
90
- | Option | Description | Default |
91
- |--------------|------------------------------------------------------------------------------|--------------------|
92
- | outputFolder | Path to results folder. | `./allure-results` |
93
- | detail | Hide `pw:api` and `hooks` steps in report. [See below](#hooks-and-api-calls) | `true` |
94
- | suiteTitle | Use test title instead of `allure.suite()`. [See below](#suit-title) | `true` |
95
- | links | Allure Runtime API links templates. [See below](#links-usage) | `undefined` |
96
-
97
- ### Options Usage
98
-
99
- ```js
100
- module.exports = {
101
- reporter: [
102
- [
103
- "allure-playwright",
104
- {
105
- detail: true,
106
- outputFolder: "my-allure-results",
107
- suiteTitle: false,
108
- },
109
- ],
110
- ],
111
- };
69
+ allure open ./allure-report
112
70
  ```
113
71
 
114
- ### Options for Allure TestOps compatibility
115
-
116
- After exporting test results into Allure TestOps, the results may contain extra steps with
117
- Playwright’s API calls, as
118
- well as collisions in the name of the suits.
119
-
120
- #### Hooks and API calls
72
+ ## The documentation
121
73
 
122
- By default, each step of the `test.step()` functions contains subsections Playwright’s API methods
123
- calls.
74
+ Learn more about Allure Playwright from the official documentation at
75
+ [https://allurereport.org/docs/playwright/](https://allurereport.org/docs/playwright/).
124
76
 
125
- The report looks like:
77
+ ## Allure Playwright options
126
78
 
127
- ```text
128
- > Before Hooks
129
- > browserContext.newPage
130
-
131
- > Open example.com
132
- > page.goto( https://example.com/)
133
-
134
- > Expect page text
135
- > expect.toBeVisible
136
-
137
- > After Hooks
138
- > browserContext.close
139
- ```
79
+ Use following options to configure Allure Playwright:
140
80
 
141
- To hide steps with `Before / After hooks` and API calls `page / expect / browser` set the
142
- option `detail: false`
81
+ | Option | Description | Default |
82
+ |-----------------|----------------------------------------------------------------------------------------------------------------------|--------------------|
83
+ | resultsDir | The path of the results folder. | `./allure-results` |
84
+ | detail | Hide the `pw:api` and `hooks` steps in report. | `true` |
85
+ | suiteTitle | Use test title instead of `allure.suite()`. | `true` |
86
+ | links | Allure Runtime API link templates. | `undefined` |
87
+ | environmentInfo | A set of key-value pairs to display in the Environment section of the report | `undefined` |
88
+ | categories | An array of category definitions, each describing a [category of defects](https://allurereport.org/docs/categories/) | `undefined` |
143
89
 
144
- #### Suite title
145
-
146
- By default, the reporter uses the test file path as the suite name.
147
-
148
- If tests uses the `allure.suite()` and it's value must be used in Allure TestOps custom fields, then
149
- set the option `suiteTitle: false`
150
-
151
- ## Providing extra information
152
-
153
- Tests extra information can be provided by labels:
154
-
155
- - label
156
- - link
157
- - id
158
- - epic
159
- - feature
160
- - story
161
- - suite
162
- - parentSuite
163
- - subSuite
164
- - owner
165
- - severity
166
- - tag
167
- - issue
168
- - tms
169
-
170
- ### Labels Usage
90
+ Here is an example of the reporter configuration:
171
91
 
172
92
  ```js
173
- import { test, expect } from "@playwright/test";
174
- import { label } from "allure-js-commons";
175
-
176
- test("basic test", async ({page}, testInfo) => {
177
- await label("labelName", "labelValue");
178
- });
179
- ```
180
-
181
- ### Links Usage
93
+ import { defineConfig } from '@playwright/test';
94
+ import os from "node:os";
182
95
 
183
- ```js
184
- import { test, expect } from "@playwright/test";
185
- import { link, issue } from "allure-js-commons";
186
-
187
- test("basic test", async ({ page }, testInfo) => {
188
- await link("https://playwright.dev", "link-type", "playwright-site"); // link with name and type
189
- await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
190
- });
191
- ```
192
-
193
- You can also configure links formatters to make usage much more convenient. `%s`
194
- in `urlTemplate` parameter will be replaced by given value.
195
-
196
- ```diff
197
- module.exports = {
96
+ export default defineConfig({
198
97
  reporter: [
199
98
  [
200
99
  "allure-playwright",
201
100
  {
202
101
  detail: true,
203
- outputFolder: "my-allure-results",
204
- + links: [
205
- + {
206
- + type: "issue",
207
- + urlTemplate: "https://example.org/issues/%s",
208
- + nameTemplate: "Issue: %s",
209
- + },
210
- + {
211
- + type: "tms",
212
- + urlTemplate: "https://example.org/tasks/%s"
213
- + },
214
- + {
215
- + type: "custom",
216
- + urlTemplate: "https://example.org/custom/%s"
217
- + },
218
- + ]
219
- },
220
- ],
221
- ],
222
- };
223
- ```
224
-
225
- Then you can assign link using shorter notation:
226
-
227
- ```js
228
- import {test, expect} from "@playwright/test";
229
- import {issue, tms, link} from "allure-js-commons";
230
-
231
- test("basic test", async () => {
232
- await issue("Issue Name", "352");
233
- await tms("Task Name", "352");
234
- await link("352", "Link name", "custom");
235
- });
236
- ```
237
-
238
- ### Id Usage
239
-
240
- ```js
241
- import {test, expect} from "@playwright/test";
242
- import {allure, LabelName} from "allure-playwright";
243
-
244
- test("basic test", async ({page}, testInfo) => {
245
- await allure.id("420");
246
- });
247
- ```
248
-
249
- ### Epics Usage
250
-
251
- ```js
252
- import {test, expect} from "@playwright/test";
253
- import {allure} from "allure-playwright";
254
-
255
- test("basic test", async ({page}, testInfo) => {
256
- await allure.epic("Some Epic");
257
- });
258
- ```
259
-
260
- ### Stories Usage
261
-
262
- ```js
263
- import {test, expect} from "@playwright/test";
264
- import {allure} from "allure-playwright";
265
-
266
- test("basic test", async ({page}, testInfo) => {
267
- await allure.story("Some Story");
268
- });
269
- ```
270
-
271
- ### Screenshot usage
272
-
273
- ```ts
274
- import {test, expect} from "@playwright/test";
275
- import {allure} from "allure-playwright";
276
-
277
- test("basic test", async ({page}, testInfo) => {
278
- await allure.attachment("basic-page-screen", await page.screenshot(), {
279
- contentType: "image/png",
280
- });
281
- });
282
- ```
283
-
284
- ### Attachments Usage
285
-
286
- ```js
287
- import {test, expect} from "@playwright/test";
288
- import {allure} from "allure-playwright";
289
-
290
- export const TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"];
291
-
292
- test("basic test", async ({page}, testInfo) => {
293
- await allure.attachment("TODO_ITEMS", JSON.stringify(TODO_ITEMS), {
294
- contentType: "application/json",
295
- });
296
- });
297
- ```
298
-
299
- ### Steps usage
300
-
301
- ```ts
302
- import {test, expect} from "@playwright/test";
303
- import {allure} from "allure-playwright";
304
-
305
- export const TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"];
306
-
307
- test("basic test", async ({page}, testInfo) => {
308
- await allure.step("Visit todolist page", async () => {
309
- await page.goto("https://demo.playwright.dev/todomvc");
310
- });
311
-
312
- await allure.step("Create 1st todo.", async () => {
313
- await page.locator(".new-todo").fill(TODO_ITEMS[0]);
314
- await page.locator(".new-todo").press("Enter");
315
- });
316
-
317
- await expect(
318
- page.locator(".view label"),
319
- "Make sure the list only has one todo item.",
320
- ).toHaveText([TODO_ITEMS[0]]);
321
- });
322
- ```
323
-
324
- ### Parameters usage
325
-
326
- ```ts
327
- import {test, expect} from "@playwright/test";
328
- import {allure} from "allure-playwright";
329
-
330
- test("basic test", async ({page}, testInfo) => {
331
- await allure.parameter("parameterName", "parameterValue");
332
- });
333
- ```
334
-
335
- Also parameter takes an third optional parameter with the hidden and excluded options:
336
- `mode: "hidden" | "masked"` - `masked` hide parameter value to secure sensitive data, and `hidden`
337
- entirely hide parameter from report
338
-
339
- `excluded: true` - excludes parameter from the history
340
-
341
- ```ts
342
- import {test, expect} from "@playwright/test";
343
- import {allure} from "allure-playwright";
344
-
345
- test("basic test", async ({page}, testInfo) => {
346
- await allure.parameter("parameterName", "parameterValue", {mode: "masked", excluded: true});
347
- });
348
- ```
349
-
350
- ### Selective test execution
351
-
352
- Allure allow you to execute only a subset of tests. This is useful when you want to run only a
353
- specific test or a group of tests.
354
-
355
- To enable this feature, you need to add the following code to your `playwright.config.js`:
356
-
357
- ```diff
358
- + import { testPlanFilter } from "allure-playwright/dist/testplan";
359
- export default {
360
- reporter: [
361
- [
362
- "allure-playwright",
363
- ],
364
- ],
365
- projects: [
366
- {
367
- name: "chromium",
368
- },
369
- ],
370
- + grep: testPlanFilter()
371
- };
372
- ```
373
-
374
- Allure will read `ALLURE_TESTPLAN_PATH` environment variable and read testplan from the specified
375
- file.
376
-
377
- ### EnvironmentInfo usage
378
-
379
- Allure allows you to add environment information to the report. This is useful when you want to add
380
- some additional information to the report.
381
-
382
- to enable this feature, you need to add the following field to your `playwright.config.js`:
383
-
384
- ```diff
385
- export default {
386
- reporter: [
387
- [
388
- "allure-playwright",
389
- {
390
- + environmentInfo: {
391
- + E2E_NODE_VERSION: process.version,
392
- + E2E_OS: process.platform,
393
- + },
102
+ resultsDir: "my-allure-results",
103
+ suiteTitle: false,
104
+ links: {
105
+ link: {
106
+ urlTemplate: "https://github.com/allure-framework/allure-js/blob/main/%s",
107
+ },
108
+ issue: {
109
+ urlTemplate: "https://github.com/allure-framework/allure-js/issues/%s",
110
+ nameTemplate: "ISSUE-%s",
111
+ },
112
+ },
113
+ environmentInfo: {
114
+ OS: os.platform(),
115
+ Architecture: os.arch(),
116
+ NodeVersion: process.version,
117
+ },
118
+ categories: [
119
+ {
120
+ name: "Missing file errors",
121
+ messageRegex: /^ENOENT: no such file or directory/,
122
+ },
123
+ ],
394
124
  },
395
125
  ],
396
126
  ],
397
- };
398
- ```
399
-
400
- ### Visual comparisons usage
401
-
402
- Allure allows you to add visual comparisons to the report. This is useful when you want to add some
403
- additional information to the report.
404
-
405
- ```ts
406
- import {test, expect} from "@playwright/test";
407
-
408
- test("screendiff", async ({page}) => {
409
- await page.goto("https://playwright.dev/");
410
- await expect(page).toHaveScreenshot();
411
- });
412
- ```
413
-
414
- If screenshots don't match, the report shows difference between them.
415
-
416
- ![screendiff-preview](./docs/screendiff.jpg)
417
-
418
- ### Passing metadata from test title
419
-
420
- You also can pass allure metadata from test title.
421
- This is useful when you need to set allureId for the tests with failing before hooks. Just
422
- add `@allure.id={idValue}` for the allureId or `@allure.label.{labelName}={labelValue}` for other
423
- types of labels.
424
-
425
- ```ts
426
- import {test, expect} from "@playwright/test";
427
-
428
- test("test with allureId @allure.id=256", async ({}) => {
429
- });
430
- test("tst with severity @allure.label.severity=critical", async ({}) => {
431
- });
432
- test("test with epic @allure.label.epic=login", async ({}) => {
433
- });
434
- test("test with strangeLabel @allure.label.strangeLabel=strangeValue", async ({}) => {
435
127
  });
436
128
  ```
437
129
 
438
- > **Warning**
439
- > Note that changing title can cause creating new testcases in history.
440
- > To fix this please add `@allure.id={yourTestCaseId}` to the test name if you passing allure
441
- > metadata from test title
130
+ More details about Allure Playwright configuration are available at [https://allurereport.org/docs/playwright-configuration/](https://allurereport.org/docs/playwright-configuration/).