allure-cucumberjs 3.0.5 → 3.0.7

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.
Files changed (2) hide show
  1. package/README.md +60 -175
  2. package/package.json +20 -9
package/README.md CHANGED
@@ -12,217 +12,102 @@
12
12
 
13
13
  ---
14
14
 
15
- ## Installation
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
- export default AllureCucumberReporter;
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
- Then add following lines to the CucumberJS configuration file:
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
- ```diff
35
- // config.js
36
- export default {
37
- + format: "./path/to/reporter.js",
38
- };
39
- ```
22
+ ## Installation
40
23
 
41
- And then run CLI with `config` parameter:
24
+ Install `allure-cucumberjs` using a package manager of your choice. For example:
42
25
 
43
26
  ```shell
44
- cucumber-js --config ./config.js
27
+ npm install -D allure-cucumberjs
45
28
  ```
46
29
 
47
- ## Reporter options
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
- Some reporter settings can be set by following options:
32
+ ## Usage
50
33
 
51
- | Option | Description | Default |
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
- ## Using Allure API
58
-
59
- To start using Allure Runtime API you need to add the following import into your `./feature/support/world.js` file:
60
-
61
- ```js
62
- import "allure-cucumberjs";
36
+ ```json
37
+ {
38
+ "default": {
39
+ "format": [
40
+ "allure-cucumberjs/reporter"
41
+ ]
42
+ }
43
+ }
63
44
  ```
64
45
 
65
- Then, you can call Allure Runtime API methods directly in your step definitions:
46
+ > Alternatively, you may specify the formatter via the CLI:
47
+ > ```shell
48
+ > npx cucumber-js --format allure-cucumberjs/reporter
49
+ > ```
66
50
 
67
- ```js
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
- Given(/my step/, async () => {
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
+ You may select another location, or further customize the formatter's behavior with [the configuration options](https://allurereport.org/docs/cucumberjs-configuration/).
76
54
 
77
- await step("by the way, body function can be arrow one", async () => {
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
- If you prefer to use custom Allure World instead of global Allure API, you can use `AllureCucumberWorld` class:
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
- ```js
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
- await self.step("by the way, body function can be arrow one", async function() {
109
- await self.label("label_name", "label_value");
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
- If you run your Cucumber features using single thread mode, `AllureCucumberWorld` is set automatically.
65
+ Open the generated report:
116
66
 
117
- ### Links usage
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
- You can also configure links formatters to make usage much more convenient. `%s`
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
- Then you can assign link using shorter notation:
73
+ Enhance the report by utilizing the Allure API:
156
74
 
157
75
  ```js
158
- const { Given } = require("@cucumber/cucumber");
159
- import { link, issue, tms } from "allure-js-commons";
160
-
161
- Given("step name", async () => {
162
- await issue("351");
163
- await issue("352", "Issue Name");
164
- await tms("351");
165
- await tms("352", "Task Name");
166
- await link("custom", "352");
167
- await link("custom", "352", "Link name");
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
- Given(/my step/, async () => {
189
- await step("step can have anonymous body function", async () => {
190
- await parameter("parameterName", "parameterValue");
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
- Also addParameter takes an third optional parameter with the hidden and excluded options:
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
- `mode: "hidden" | "masked"` - `masked` hide parameter value to secure sensitive data, and `hidden` entirely hide parameter from report
198
-
199
- `excluded: true` - excludes parameter from the history
99
+ // ...
100
+ });
200
101
 
201
- ```ts
202
- import { Given } from "@cucumber/cucumber";
203
- import { step, parameter } from "allure-js-commons";
102
+ await allure.step("Submit the form", async () => {
103
+ // ...
104
+ // const responseData = ...
204
105
 
205
- Given(/my step/, async () => {
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
- ```js
217
- import { parameter } from "allure-js-commons";
218
-
219
- await parameter('Browser', 'firefox')
110
+ // ...
220
111
  ```
221
112
 
222
- For better presentation, you can also group suites by browser names, i.e.:
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.5",
3
+ "version": "3.0.7",
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",
@@ -16,14 +27,14 @@
16
27
  },
17
28
  "exports": {
18
29
  ".": {
30
+ "types": "./dist/types/index.d.ts",
19
31
  "import": "./dist/esm/index.js",
20
- "require": "./dist/cjs/index.js",
21
- "types": "./dist/types/index.d.ts"
32
+ "require": "./dist/cjs/index.js"
22
33
  },
23
34
  "./reporter": {
35
+ "types": "./dist/types/reporter.d.ts",
24
36
  "import": "./dist/esm/reporter.js",
25
- "require": "./dist/cjs/reporter.js",
26
- "types": "./dist/types/reporter.d.ts"
37
+ "require": "./dist/cjs/reporter.js"
27
38
  }
28
39
  },
29
40
  "main": "./dist/cjs/index.js",
@@ -46,7 +57,7 @@
46
57
  "test": "vitest run"
47
58
  },
48
59
  "dependencies": {
49
- "allure-js-commons": "3.0.5"
60
+ "allure-js-commons": "3.0.7"
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.5",
78
+ "allure-vitest": "3.0.7",
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,10 +84,10 @@
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": "^6.1.2",
87
+ "npm-run-all2": "^7.0.0",
77
88
  "rimraf": "^6.0.0",
78
89
  "typescript": "^5.2.2",
79
- "vitest": "^1.6.0"
90
+ "vitest": "^2.1.5"
80
91
  },
81
92
  "peerDependencies": {
82
93
  "@cucumber/cucumber": ">=10.8.0",