allure-cucumberjs 3.0.5 → 3.0.6
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 +60 -175
- package/package.json +15 -4
package/README.md
CHANGED
|
@@ -12,217 +12,102 @@
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
Install the required packages using your favorite package manager:
|
|
18
|
-
|
|
19
|
-
```shell
|
|
20
|
-
npm add -D allure-cucumberjs
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Create `reporter.js` with following content:
|
|
24
|
-
|
|
25
|
-
```js
|
|
26
|
-
// reporter.js
|
|
27
|
-
const AllureCucumberReporter = require("allure-cucumberjs/reporter");
|
|
15
|
+
## The documentation and examples
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
The docs for Allure Cucumber.js are available at
|
|
18
|
+
[https://allurereport.org/docs/cucumberjs/](https://allurereport.org/docs/cucumberjs/).
|
|
31
19
|
|
|
32
|
-
|
|
20
|
+
Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Acucumberjs).
|
|
33
21
|
|
|
34
|
-
|
|
35
|
-
// config.js
|
|
36
|
-
export default {
|
|
37
|
-
+ format: "./path/to/reporter.js",
|
|
38
|
-
};
|
|
39
|
-
```
|
|
22
|
+
## Installation
|
|
40
23
|
|
|
41
|
-
|
|
24
|
+
Install `allure-cucumberjs` using a package manager of your choice. For example:
|
|
42
25
|
|
|
43
26
|
```shell
|
|
44
|
-
|
|
27
|
+
npm install -D allure-cucumberjs
|
|
45
28
|
```
|
|
46
29
|
|
|
47
|
-
|
|
30
|
+
> If you're a Yarn PnP user, please read [this](https://allurereport.org/docs/cucumberjs-configuration/#a-note-for-yarn-pnp-users).
|
|
48
31
|
|
|
49
|
-
|
|
32
|
+
## Usage
|
|
50
33
|
|
|
51
|
-
|
|
52
|
-
| ---------- |-------------------------------------------------------------------------------------------------| ------------------ |
|
|
53
|
-
| resultsDir | Path to results folder | `./allure-results` |
|
|
54
|
-
| links | Links templates to make runtime methods calls simpler and process Cucumber tags as Allure links | `undefined` |
|
|
55
|
-
| labels | Labels templates to process Cucumber tags as Allure labels | `undefined` |
|
|
34
|
+
Enable the `allure-cucumberjs/reporter` formatter in [the Cucumber.js configuration file](https://github.com/cucumber/cucumber-js/blob/main/docs/configuration.md):
|
|
56
35
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"default": {
|
|
39
|
+
"format": [
|
|
40
|
+
"allure-cucumberjs/reporter"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
63
44
|
```
|
|
64
45
|
|
|
65
|
-
|
|
46
|
+
> Alternatively, you may specify the formatter via the CLI:
|
|
47
|
+
> ```shell
|
|
48
|
+
> npx cucumber-js --format allure-cucumberjs/reporter
|
|
49
|
+
> ```
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
import { Given } from "@cucumber/cucumber";
|
|
69
|
-
import { label, attachment, step } from "allure-js-commons";
|
|
51
|
+
When the test run completes, the result files will be generated in the `./allure-results` directory.
|
|
70
52
|
|
|
71
|
-
|
|
72
|
-
await step("step can have anonymous body function", async () => {
|
|
73
|
-
await label("label_name", "label_value");
|
|
74
|
-
await attachment(JSON.stringify({ foo: "bar " }), "application/json");
|
|
75
|
-
});
|
|
53
|
+
IYou may select another location, or further customize the formatter's behavior with [the configuration options](https://allurereport.org/docs/cucumberjs-configuration/).
|
|
76
54
|
|
|
77
|
-
|
|
78
|
-
await label("label_name", "label_value");
|
|
79
|
-
await attachment(JSON.stringify({ foo: "bar " }), "application/json");
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Using Allure Cucumber World
|
|
55
|
+
### View the report
|
|
85
56
|
|
|
86
|
-
|
|
57
|
+
> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it.
|
|
87
58
|
|
|
88
|
-
|
|
89
|
-
import { AllureCucumberWorld } from "allure-cucumberjs";
|
|
90
|
-
import { setWorldConstructor } from "@cucumber/cucumber";
|
|
91
|
-
|
|
92
|
-
setWorldConstructor(AllureCucumberWorld);
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Then you'll be able to use Allure Runtime API through `this` in your step definition files:
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
import { Given } from "@cucumber/cucumber";
|
|
99
|
-
|
|
100
|
-
Given(/my step/, async function() {
|
|
101
|
-
const self = this;
|
|
102
|
-
|
|
103
|
-
await self.step("step can have anonymous body function", async function() {
|
|
104
|
-
await self.label("label_name", "label_value");
|
|
105
|
-
await self.attachment(JSON.stringify({ foo: "bar " }), "application/json");
|
|
106
|
-
});
|
|
59
|
+
Generate Allure Report after the tests are executed:
|
|
107
60
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
await self.attachment(JSON.stringify({ foo: "bar " }), "application/json");
|
|
111
|
-
});
|
|
112
|
-
});
|
|
61
|
+
```bash
|
|
62
|
+
allure generate ./allure-results -o ./allure-report
|
|
113
63
|
```
|
|
114
64
|
|
|
115
|
-
|
|
65
|
+
Open the generated report:
|
|
116
66
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
```js
|
|
120
|
-
const { Given } = require("@cucumber/cucumber");
|
|
121
|
-
import { link, issue, tms } from "allure-js-commons";
|
|
122
|
-
|
|
123
|
-
Given("step name", async () => {
|
|
124
|
-
await link("link_type", "https://allurereport.org", "Allure Report");
|
|
125
|
-
await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
|
|
126
|
-
await tms("Task Name", "https://github.com/allure-framework/allure-js/tasks/352");
|
|
127
|
-
});
|
|
67
|
+
```bash
|
|
68
|
+
allure open ./allure-report
|
|
128
69
|
```
|
|
129
70
|
|
|
130
|
-
|
|
131
|
-
in `urlTemplate` parameter will be replaced by given value.
|
|
132
|
-
|
|
133
|
-
```diff
|
|
134
|
-
// config.js
|
|
135
|
-
export default {
|
|
136
|
-
format: "./path/to/reporter.js",
|
|
137
|
-
+ formatOptions: {
|
|
138
|
-
+ links: [
|
|
139
|
-
+ {
|
|
140
|
-
+ pattern: [/@issue=(.*)/],
|
|
141
|
-
+ type: "issue",
|
|
142
|
-
+ urlTemplate: "https://example.com/issues/%s",
|
|
143
|
-
+ nameTemplate: "Issue: %s",
|
|
144
|
-
+ },
|
|
145
|
-
+ {
|
|
146
|
-
+ pattern: [/@tms=(.*)/],
|
|
147
|
-
+ type: "tms",
|
|
148
|
-
+ urlTemplate: "https://example.com/tasks/%s",
|
|
149
|
-
+ },
|
|
150
|
-
+ ],
|
|
151
|
-
+ }
|
|
152
|
-
};
|
|
153
|
-
```
|
|
71
|
+
## Allure API
|
|
154
72
|
|
|
155
|
-
|
|
73
|
+
Enhance the report by utilizing the Allure API:
|
|
156
74
|
|
|
157
75
|
```js
|
|
158
|
-
|
|
159
|
-
import
|
|
160
|
-
|
|
161
|
-
Given("
|
|
162
|
-
await
|
|
163
|
-
await
|
|
164
|
-
await
|
|
165
|
-
await
|
|
166
|
-
await
|
|
167
|
-
await
|
|
76
|
+
import { When } from "@cucumber/cucumber";
|
|
77
|
+
import * as allure from "allure-js-commons";
|
|
78
|
+
|
|
79
|
+
Given("an active user", async function () {
|
|
80
|
+
await allure.description("The test checks if an active user with a valid password can sign in to the app.");
|
|
81
|
+
await allure.epic("Signing in");
|
|
82
|
+
await allure.tags("signin", "ui", "positive");
|
|
83
|
+
await allure.issue("https://github.com/allure-framework/allure-js/issues/1", "ISSUE-1");
|
|
84
|
+
await allure.owner("eroshenkoam");
|
|
85
|
+
await allure.parameter("browser", "chrome");
|
|
86
|
+
|
|
87
|
+
this.user = await createAnActiveUserInDb();
|
|
168
88
|
});
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
Links patterns also work with Cucumber tags which match `pattern` parameter:
|
|
172
|
-
|
|
173
|
-
```gherkin
|
|
174
|
-
@issue=0
|
|
175
|
-
Feature: links
|
|
176
|
-
|
|
177
|
-
@issue=1 @tms=2
|
|
178
|
-
Scenario: a
|
|
179
|
-
Given a step
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Parameters usage
|
|
183
|
-
|
|
184
|
-
```ts
|
|
185
|
-
import { Given } from "@cucumber/cucumber";
|
|
186
|
-
import { step, parameter } from "allure-js-commons";
|
|
187
89
|
|
|
188
|
-
|
|
189
|
-
await step("
|
|
190
|
-
|
|
90
|
+
When("they sign in with a valid password", async function () {
|
|
91
|
+
await allure.step("Navigate to the sign in page", async () => {
|
|
92
|
+
// ...
|
|
191
93
|
});
|
|
192
|
-
});
|
|
193
|
-
```
|
|
194
94
|
|
|
195
|
-
|
|
95
|
+
await allure.step("Fill the sign-in form", async (stepContext) => {
|
|
96
|
+
await stepContext.parameter("login", this.user.login);
|
|
97
|
+
await stepContext.parameter("password", this.user.password, "masked");
|
|
196
98
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
`excluded: true` - excludes parameter from the history
|
|
99
|
+
// ...
|
|
100
|
+
});
|
|
200
101
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
102
|
+
await allure.step("Submit the form", async () => {
|
|
103
|
+
// ...
|
|
104
|
+
// const responseData = ...
|
|
204
105
|
|
|
205
|
-
|
|
206
|
-
await step("step can have anonymous body function", async () => {
|
|
207
|
-
await parameter("parameterName", "parameterValue", { mode: "hidden", excluded: true });
|
|
106
|
+
await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" });
|
|
208
107
|
});
|
|
209
108
|
});
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## Cross-browser testing
|
|
213
|
-
|
|
214
|
-
For cross-browser testing simply add a parameter using Allure API with the browser name to the `World` instance inside your scenario, i.e.:
|
|
215
109
|
|
|
216
|
-
|
|
217
|
-
import { parameter } from "allure-js-commons";
|
|
218
|
-
|
|
219
|
-
await parameter('Browser', 'firefox')
|
|
110
|
+
// ...
|
|
220
111
|
```
|
|
221
112
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
```js
|
|
225
|
-
import { parentSuite } from "allure-js-commons";
|
|
226
|
-
|
|
227
|
-
await parentSuite('Firefox')
|
|
228
|
-
```
|
|
113
|
+
More details about the API are available at [https://allurereport.org/docs/cucumberjs-reference/](https://allurereport.org/docs/cucumberjs-reference/).
|
package/package.json
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "allure-cucumberjs",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"description": "Allure Cucumber.JS integration",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"allure",
|
|
7
|
+
"cucumber",
|
|
8
|
+
"bdd",
|
|
9
|
+
"html",
|
|
10
|
+
"test",
|
|
11
|
+
"report",
|
|
12
|
+
"reporter",
|
|
13
|
+
"testing",
|
|
14
|
+
"testops"
|
|
15
|
+
],
|
|
5
16
|
"homepage": "https://allurereport.org/",
|
|
6
17
|
"repository": {
|
|
7
18
|
"type": "git",
|
|
@@ -46,7 +57,7 @@
|
|
|
46
57
|
"test": "vitest run"
|
|
47
58
|
},
|
|
48
59
|
"dependencies": {
|
|
49
|
-
"allure-js-commons": "3.0.
|
|
60
|
+
"allure-js-commons": "3.0.6"
|
|
50
61
|
},
|
|
51
62
|
"devDependencies": {
|
|
52
63
|
"@babel/cli": "^7.24.6",
|
|
@@ -64,7 +75,7 @@
|
|
|
64
75
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
65
76
|
"@typescript-eslint/parser": "^8.0.0",
|
|
66
77
|
"allure-commandline": "^2.29.0",
|
|
67
|
-
"allure-vitest": "3.0.
|
|
78
|
+
"allure-vitest": "3.0.6",
|
|
68
79
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
69
80
|
"eslint": "^8.57.0",
|
|
70
81
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -73,7 +84,7 @@
|
|
|
73
84
|
"eslint-plugin-n": "^17.10.1",
|
|
74
85
|
"eslint-plugin-no-null": "^1.0.2",
|
|
75
86
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
76
|
-
"npm-run-all2": "^
|
|
87
|
+
"npm-run-all2": "^7.0.0",
|
|
77
88
|
"rimraf": "^6.0.0",
|
|
78
89
|
"typescript": "^5.2.2",
|
|
79
90
|
"vitest": "^1.6.0"
|