allure-playwright 2.15.1 → 3.0.0-beta.10
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 +64 -303
- package/dist/cjs/autoconfig.js +6 -0
- package/dist/cjs/autoconfig.js.map +1 -0
- package/dist/cjs/index.js +595 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/legacy.js +178 -0
- package/dist/cjs/legacy.js.map +1 -0
- package/dist/cjs/model.js +2 -0
- package/dist/cjs/model.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/runtime.js +127 -0
- package/dist/cjs/runtime.js.map +1 -0
- package/dist/cjs/testplan.js +20 -0
- package/dist/cjs/testplan.js.map +1 -0
- package/dist/cjs/utils.js +20 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/autoconfig.js +4 -0
- package/dist/esm/autoconfig.js.map +1 -0
- package/dist/esm/index.js +578 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/legacy.js +170 -0
- package/dist/esm/legacy.js.map +1 -0
- package/dist/esm/model.js +2 -0
- package/dist/esm/model.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/runtime.js +121 -0
- package/dist/esm/runtime.js.map +1 -0
- package/dist/esm/testplan.js +14 -0
- package/dist/esm/testplan.js.map +1 -0
- package/dist/esm/utils.js +14 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/autoconfig.d.ts +1 -0
- package/dist/types/index.d.ts +58 -0
- package/dist/types/legacy.d.ts +40 -0
- package/dist/types/model.d.ts +5 -0
- package/dist/types/runtime.d.ts +11 -0
- package/dist/types/utils.d.ts +3 -0
- package/package.json +57 -21
- package/dist/helpers.d.ts +0 -30
- package/dist/helpers.js +0 -112
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -41
- package/dist/index.js +0 -316
- package/dist/index.js.map +0 -1
- package/dist/testplan.js +0 -16
- package/dist/testplan.js.map +0 -1
- /package/dist/{testplan.d.ts → types/testplan.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -14,356 +14,117 @@
|
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
npm i -D @playwright/test allure-playwright
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
or via yarn:
|
|
17
|
+
Use your favorite node package manager to install the package:
|
|
22
18
|
|
|
23
19
|
```bash
|
|
24
|
-
|
|
20
|
+
npm i -D allure-playwright
|
|
25
21
|
```
|
|
26
22
|
|
|
27
23
|
## Usage
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
Add `allure-playwright` as the reporter in the Playwright configuration file:
|
|
30
26
|
|
|
31
27
|
```js
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
import { defineConfig } from '@playwright/test';
|
|
29
|
+
|
|
30
|
+
export default defineConfig({
|
|
31
|
+
reporter: "allure-playwright",
|
|
32
|
+
});
|
|
35
33
|
```
|
|
36
34
|
|
|
37
|
-
Or
|
|
35
|
+
Or, if you want to use more than one reporter:
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
import { defineConfig } from '@playwright/test';
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
reporter: [["line"], ["allure-playwright"]],
|
|
42
|
+
});
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
Or pass the same
|
|
45
|
+
Or pass the same values via the command line:
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
48
|
npx playwright test --reporter=line,allure-playwright
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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)).
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
ALLURE_RESULTS_DIR=my-allure-results npx playwright test --reporter=line,allure-playwright
|
|
57
|
-
```
|
|
55
|
+
### View the report
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
set ALLURE_RESULTS_DIR=my-allure-results
|
|
63
|
-
npx playwright test --reporter=line,allure-playwright
|
|
64
|
-
```
|
|
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.
|
|
65
59
|
|
|
66
60
|
Generate Allure Report:
|
|
67
61
|
|
|
68
62
|
```bash
|
|
69
|
-
allure generate
|
|
63
|
+
allure generate ./allure-results -o ./allure-report
|
|
70
64
|
```
|
|
71
65
|
|
|
72
66
|
Open Allure Report:
|
|
73
67
|
|
|
74
68
|
```bash
|
|
75
|
-
allure open allure-report
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Reporter options
|
|
79
|
-
|
|
80
|
-
Some reporter settings can set by following options:
|
|
81
|
-
|
|
82
|
-
| Option | Description | Default |
|
|
83
|
-
| ------------ | ---------------------------------------------------------------------------- | ------------------ |
|
|
84
|
-
| outputFolder | Path to results folder. | `./allure-results` |
|
|
85
|
-
| detail | Hide `pw:api` and `hooks` steps in report. [See below](#hooks-and-api-calls) | `true` |
|
|
86
|
-
| suiteTitle | Use test title instead of `allure.suite()`. [See below](#suit-title) | `true` |
|
|
87
|
-
|
|
88
|
-
### Options Usage
|
|
89
|
-
|
|
90
|
-
```js
|
|
91
|
-
const config = {
|
|
92
|
-
reporter: [
|
|
93
|
-
[
|
|
94
|
-
"allure-playwright",
|
|
95
|
-
{
|
|
96
|
-
detail: true,
|
|
97
|
-
outputFolder: "my-allure-results",
|
|
98
|
-
suiteTitle: false,
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
],
|
|
102
|
-
};
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Options for Allure TestOps compatibility
|
|
106
|
-
|
|
107
|
-
After exporting test results into Allure TestOps, the results may contain extra steps with Playwright’s API calls, as
|
|
108
|
-
well as collisions in the name of the suits.
|
|
109
|
-
|
|
110
|
-
#### Hooks and API calls
|
|
111
|
-
|
|
112
|
-
By default, each step of the `test.step()` functions contains subsections Playwright’s API methods calls.
|
|
113
|
-
|
|
114
|
-
The report looks like:
|
|
115
|
-
|
|
116
|
-
```text
|
|
117
|
-
> Before Hooks
|
|
118
|
-
> browserContext.newPage
|
|
119
|
-
|
|
120
|
-
> Open example.com
|
|
121
|
-
> page.goto( https://example.com/)
|
|
122
|
-
|
|
123
|
-
> Expect page text
|
|
124
|
-
> expect.toBeVisible
|
|
125
|
-
|
|
126
|
-
> After Hooks
|
|
127
|
-
> browserContext.close
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
To hide steps with `Before / After hooks` and API calls `page / expect / browser` set the option `detail: false`
|
|
131
|
-
|
|
132
|
-
#### Suite title
|
|
133
|
-
|
|
134
|
-
By default, the reporter uses the test file path as the suite name.
|
|
135
|
-
|
|
136
|
-
If tests uses the `allure.suite()` and it's value must be used in Allure TestOps custom fields, then set the option `suiteTitle: false`
|
|
137
|
-
|
|
138
|
-
## Providing extra information
|
|
139
|
-
|
|
140
|
-
Tests extra information can be provided by labels:
|
|
141
|
-
|
|
142
|
-
- label
|
|
143
|
-
- link
|
|
144
|
-
- id
|
|
145
|
-
- epic
|
|
146
|
-
- feature
|
|
147
|
-
- story
|
|
148
|
-
- suite
|
|
149
|
-
- parentSuite
|
|
150
|
-
- subSuite
|
|
151
|
-
- owner
|
|
152
|
-
- severity
|
|
153
|
-
- tag
|
|
154
|
-
- issue
|
|
155
|
-
- tms
|
|
156
|
-
|
|
157
|
-
### Labels Usage
|
|
158
|
-
|
|
159
|
-
```js
|
|
160
|
-
import { test, expect } from "@playwright/test";
|
|
161
|
-
import { allure } from "allure-playwright";
|
|
162
|
-
|
|
163
|
-
test("basic test", async ({ page }, testInfo) => {
|
|
164
|
-
await allure.label("labelName", "labelValue");
|
|
165
|
-
});
|
|
69
|
+
allure open ./allure-report
|
|
166
70
|
```
|
|
167
71
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
```js
|
|
171
|
-
import { test, expect } from "@playwright/test";
|
|
172
|
-
import { allure } from "allure-playwright";
|
|
72
|
+
## The documentation
|
|
173
73
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
await allure.issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
|
|
177
|
-
});
|
|
178
|
-
```
|
|
74
|
+
Learn more about Allure Playwright from the official documentation at
|
|
75
|
+
[https://allurereport.org/docs/playwright/](https://allurereport.org/docs/playwright/).
|
|
179
76
|
|
|
180
|
-
|
|
77
|
+
## Allure Playwright options
|
|
181
78
|
|
|
182
|
-
|
|
183
|
-
import { test, expect } from "@playwright/test";
|
|
184
|
-
import { allure, LabelName } from "allure-playwright";
|
|
79
|
+
Use following options to configure Allure Playwright:
|
|
185
80
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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` |
|
|
190
89
|
|
|
191
|
-
|
|
90
|
+
Here is an example of the reporter configuration:
|
|
192
91
|
|
|
193
92
|
```js
|
|
194
|
-
import {
|
|
195
|
-
import
|
|
196
|
-
|
|
197
|
-
test("basic test", async ({ page }, testInfo) => {
|
|
198
|
-
await allure.epic("Some Epic");
|
|
199
|
-
});
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Stories Usage
|
|
93
|
+
import { defineConfig } from '@playwright/test';
|
|
94
|
+
import os from "node:os";
|
|
203
95
|
|
|
204
|
-
|
|
205
|
-
import { test, expect } from "@playwright/test";
|
|
206
|
-
import { allure } from "allure-playwright";
|
|
207
|
-
|
|
208
|
-
test("basic test", async ({ page }, testInfo) => {
|
|
209
|
-
await allure.story("Some Story");
|
|
210
|
-
});
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### Screenshot usage
|
|
214
|
-
|
|
215
|
-
```ts
|
|
216
|
-
import { test, expect } from "@playwright/test";
|
|
217
|
-
import { allure } from "allure-playwright";
|
|
218
|
-
|
|
219
|
-
test("basic test", async ({ page }, testInfo) => {
|
|
220
|
-
await allure.attachment("basic-page-screen", await page.screenshot(), {
|
|
221
|
-
contentType: "image/png",
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Attachments Usage
|
|
227
|
-
|
|
228
|
-
```js
|
|
229
|
-
import { test, expect } from "@playwright/test";
|
|
230
|
-
import { allure } from "allure-playwright";
|
|
231
|
-
|
|
232
|
-
export const TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"];
|
|
233
|
-
|
|
234
|
-
test("basic test", async ({ page }, testInfo) => {
|
|
235
|
-
await allure.attachment("TODO_ITEMS", JSON.stringify(TODO_ITEMS), {
|
|
236
|
-
contentType: "application/json",
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Steps usage
|
|
242
|
-
|
|
243
|
-
```ts
|
|
244
|
-
import { test, expect } from "@playwright/test";
|
|
245
|
-
import { allure } from "allure-playwright";
|
|
246
|
-
|
|
247
|
-
export const TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"];
|
|
248
|
-
|
|
249
|
-
test("basic test", async ({ page }, testInfo) => {
|
|
250
|
-
await allure.step("Visit todolist page", async () => {
|
|
251
|
-
await page.goto("https://demo.playwright.dev/todomvc");
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
await allure.step("Create 1st todo.", async () => {
|
|
255
|
-
await page.locator(".new-todo").fill(TODO_ITEMS[0]);
|
|
256
|
-
await page.locator(".new-todo").press("Enter");
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
await expect(
|
|
260
|
-
page.locator(".view label"),
|
|
261
|
-
"Make sure the list only has one todo item.",
|
|
262
|
-
).toHaveText([TODO_ITEMS[0]]);
|
|
263
|
-
});
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### Parameters usage
|
|
267
|
-
|
|
268
|
-
```ts
|
|
269
|
-
import { test, expect } from "@playwright/test";
|
|
270
|
-
import { allure } from "allure-playwright";
|
|
271
|
-
|
|
272
|
-
test("basic test", async ({ page }, testInfo) => {
|
|
273
|
-
await allure.parameter("parameterName", "parameterValue");
|
|
274
|
-
});
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
Also parameter takes an third optional parameter with the hidden and excluded options:
|
|
278
|
-
`mode: "hidden" | "masked"` - `masked` hide parameter value to secure sensitive data, and `hidden` entirely hide parameter from report
|
|
279
|
-
|
|
280
|
-
`excluded: true` - excludes parameter from the history
|
|
281
|
-
|
|
282
|
-
```ts
|
|
283
|
-
import { test, expect } from "@playwright/test";
|
|
284
|
-
import { allure } from "allure-playwright";
|
|
285
|
-
|
|
286
|
-
test("basic test", async ({ page }, testInfo) => {
|
|
287
|
-
await allure.parameter("parameterName", "parameterValue", { mode: "masked", excluded: true });
|
|
288
|
-
});
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### Selective test execution
|
|
292
|
-
|
|
293
|
-
Allure allow you to execute only a subset of tests. This is useful when you want to run only a specific test or a group of tests.
|
|
294
|
-
|
|
295
|
-
To enable this feature, you need to add the following code to your `playwright.config.js`:
|
|
296
|
-
|
|
297
|
-
```diff
|
|
298
|
-
+ import { testPlanFilter } from "allure-playwright/dist/testplan";
|
|
299
|
-
export default {
|
|
300
|
-
reporter: [
|
|
301
|
-
[
|
|
302
|
-
"allure-playwright",
|
|
303
|
-
],
|
|
304
|
-
],
|
|
305
|
-
projects: [
|
|
306
|
-
{
|
|
307
|
-
name: "chromium",
|
|
308
|
-
},
|
|
309
|
-
],
|
|
310
|
-
+ grep: testPlanFilter()
|
|
311
|
-
};
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
Allure will read `ALLURE_TESTPLAN_PATH` environment variable and read testplan from the specified file.
|
|
315
|
-
|
|
316
|
-
### EnvironmentInfo usage
|
|
317
|
-
|
|
318
|
-
Allure allows you to add environment information to the report. This is useful when you want to add some additional information to the report.
|
|
319
|
-
|
|
320
|
-
to enable this feature, you need to add the following field to your `playwright.config.js`:
|
|
321
|
-
|
|
322
|
-
```diff
|
|
323
|
-
export default {
|
|
96
|
+
export default defineConfig({
|
|
324
97
|
reporter: [
|
|
325
98
|
[
|
|
326
99
|
"allure-playwright",
|
|
327
100
|
{
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
101
|
+
detail: true,
|
|
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
|
+
],
|
|
332
124
|
},
|
|
333
125
|
],
|
|
334
126
|
],
|
|
335
|
-
};
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
### Visual comparisons usage
|
|
339
|
-
|
|
340
|
-
Allure allows you to add visual comparisons to the report. This is useful when you want to add some additional information to the report.
|
|
341
|
-
|
|
342
|
-
```ts
|
|
343
|
-
import { test, expect } from "@playwright/test";
|
|
344
|
-
test("screendiff", async ({ page }) => {
|
|
345
|
-
await page.goto("https://playwright.dev/");
|
|
346
|
-
await expect(page).toHaveScreenshot();
|
|
347
127
|
});
|
|
348
128
|
```
|
|
349
129
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-

|
|
353
|
-
|
|
354
|
-
### Passing metadata from test title
|
|
355
|
-
|
|
356
|
-
You also can pass allure metadata from test title.
|
|
357
|
-
This is useful when you need to set allureId for the tests with failing before hooks. Just add `@allure.id={idValue}` for the allureId or `@allure.label.{labelName}={labelValue}` for other types of labels.
|
|
358
|
-
|
|
359
|
-
```ts
|
|
360
|
-
import { test, expect } from "@playwright/test";
|
|
361
|
-
test("test with allureId @allure.id=256", async ({}) => {});
|
|
362
|
-
test("tst with severity @allure.label.severity=critical", async ({}) => {});
|
|
363
|
-
test("test with epic @allure.label.epic=login", async ({}) => {});
|
|
364
|
-
test("test with strangeLabel @allure.label.strangeLabel=strangeValue", async ({}) => {});
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
> **Warning**
|
|
368
|
-
> Note that changing title can cause creating new testcases in history.
|
|
369
|
-
> To fix this please add `@allure.id={yourTestCaseId}` to the test name if you passing allure 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/).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoconfig.js","names":["_runtime","require","_runtime2","setGlobalTestRuntime","AllurePlaywrightTestRuntime"],"sources":["../../src/autoconfig.ts"],"sourcesContent":["import { setGlobalTestRuntime } from \"allure-js-commons/sdk/runtime\";\nimport { AllurePlaywrightTestRuntime } from \"./runtime.js\";\n\nsetGlobalTestRuntime(new AllurePlaywrightTestRuntime());\n"],"mappings":";;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,6BAAoB,EAAC,IAAIC,qCAA2B,CAAC,CAAC,CAAC","ignoreList":[]}
|