cucumberjs-qase-reporter 2.2.0 → 2.2.1

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
@@ -1,142 +1,281 @@
1
- # Qase TMS Cucumber JS reporter
1
+ # [Qase TestOps](https://qase.io) CucumberJS Reporter
2
2
 
3
- Publish results simple and easy.
3
+ [![License](https://lxgaming.github.io/badges/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
4
+ [![npm downloads](https://img.shields.io/npm/dm/cucumberjs-qase-reporter.svg)](https://www.npmjs.com/package/cucumberjs-qase-reporter)
4
5
 
5
- To install the latest version, run:
6
+ Qase CucumberJS Reporter enables seamless integration between your CucumberJS tests and [Qase TestOps](https://qase.io), providing automatic test result reporting, test case management, and comprehensive test analytics.
7
+
8
+ ## Features
9
+
10
+ - Link automated tests to Qase test cases by ID using Gherkin tags
11
+ - Auto-create test cases from your Gherkin scenarios
12
+ - Report test results with rich metadata (fields, attachments, steps)
13
+ - Native Gherkin step reporting (Given/When/Then automatically mapped)
14
+ - Multi-project reporting support
15
+ - Flexible configuration (file, environment variables, CucumberJS formatter)
16
+ - Network Profiler for automatic HTTP request capture
17
+
18
+ ## Installation
6
19
 
7
20
  ```sh
8
- npm install -D cucumberjs-qase-reporter
21
+ npm install --save-dev cucumberjs-qase-reporter
9
22
  ```
10
23
 
11
- ## Updating from v1
24
+ ## Quick Start
12
25
 
13
- To update a test project using cucumberjs-qase-reporter@v1 to version 2:
26
+ **1. Create `qase.config.json` in your project root:**
14
27
 
15
- 1. Update reporter configuration in `qase.config.json` and/or environment variables —
16
- see the [configuration reference](#configuration) below.
28
+ ```json
29
+ {
30
+ "mode": "testops",
31
+ "testops": {
32
+ "project": "YOUR_PROJECT_CODE",
33
+ "api": {
34
+ "token": "YOUR_API_TOKEN"
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ **2. Add Qase ID tag to your Gherkin scenario:**
41
+
42
+ ```gherkin
43
+ Feature: User Authentication
44
+
45
+ @QaseID=1
46
+ Scenario: Successful login
47
+ Given I am on the login page
48
+ When I enter valid credentials
49
+ Then I should be logged in
50
+ ```
17
51
 
18
- ## Getting started
52
+ **3. Run your tests with the reporter:**
19
53
 
20
- The Cucumber JS reporter can auto-generate test cases
21
- and suites from your test data.
22
- Test results of subsequent test runs will match the same test cases
23
- as long as their names and file paths don't change.
54
+ ```sh
55
+ QASE_MODE=testops npx cucumber-js -f cucumberjs-qase-reporter
56
+ ```
24
57
 
25
- You can also annotate the tests with the IDs of existing test cases
26
- from Qase.io before executing tests. It's a more reliable way to bind
27
- autotests to test cases, that persists when you rename, move, or
28
- parameterize your tests.
58
+ ## Configuration
29
59
 
30
- For more information, see the [Usage Guide](docs/usage.md).
60
+ The reporter is configured via (in order of priority):
31
61
 
32
- For example:
62
+ 1. **CucumberJS CLI flags** (highest priority)
63
+ 2. **Environment variables** (`QASE_*`)
64
+ 3. **Config file** (`qase.config.json`)
33
65
 
66
+ ### CucumberJS Formatter Configuration
67
+
68
+ Run CucumberJS with the Qase formatter:
69
+
70
+ ```sh
71
+ npx cucumber-js -f cucumberjs-qase-reporter features -r step_definitions
72
+ ```
73
+
74
+ Or configure in your `cucumber.js` profile:
75
+
76
+ ```javascript
77
+ // cucumber.js
78
+ module.exports = {
79
+ default: {
80
+ format: ['progress', 'cucumberjs-qase-reporter'],
81
+ requireModule: ['ts-node/register'],
82
+ require: ['step_definitions/**/*.js'],
83
+ },
84
+ };
85
+ ```
86
+
87
+ ### Minimal Configuration
88
+
89
+ | Option | Environment Variable | Description |
90
+ |--------|---------------------|-------------|
91
+ | `mode` | `QASE_MODE` | Set to `testops` to enable reporting |
92
+ | `testops.project` | `QASE_TESTOPS_PROJECT` | Your Qase project code |
93
+ | `testops.api.token` | `QASE_TESTOPS_API_TOKEN` | Your Qase API token |
94
+
95
+ ### Example `qase.config.json`
96
+
97
+ ```json
98
+ {
99
+ "mode": "testops",
100
+ "fallback": "report",
101
+ "testops": {
102
+ "project": "YOUR_PROJECT_CODE",
103
+ "api": {
104
+ "token": "YOUR_API_TOKEN"
105
+ },
106
+ "run": {
107
+ "title": "CucumberJS Automated Run"
108
+ },
109
+ "batch": {
110
+ "size": 100
111
+ }
112
+ },
113
+ "report": {
114
+ "driver": "local",
115
+ "connection": {
116
+ "local": {
117
+ "path": "./build/qase-report",
118
+ "format": "json"
119
+ }
120
+ }
121
+ }
122
+ }
123
+ ```
124
+
125
+ > **Full configuration reference:** See [qase-javascript-commons](../qase-javascript-commons/README.md) for all available options including logging, status mapping, execution plans, and more.
126
+
127
+ ## Usage
128
+
129
+ ### Link Tests with Test Cases
130
+
131
+ Associate your scenarios with Qase test cases using Gherkin tags:
132
+
133
+ **Single ID:**
34
134
  ```gherkin
35
- Feature: Cucumber documentation
36
- As a user of cucumber.js
37
- I want to have documentation on cucumber
38
- So I can write better applications
135
+ Feature: User Authentication
39
136
 
40
137
  @QaseID=1
41
- Scenario: Usage documentation
42
- Given I am on the cucumber.js GitHub repository
43
- When I go to the README file
44
- Then I should see a "Cool" section
138
+ Scenario: Valid login
139
+ Given I am on the login page
140
+ When I enter valid credentials
141
+ Then I should see the dashboard
142
+ ```
143
+
144
+ **Multiple IDs:**
145
+ ```gherkin
146
+ Feature: User Authentication
45
147
 
46
- @QaseID=2
47
- @QaseFields={'severity':'high'}
48
- Scenario: Status badges 2
49
- Given I am on the cucumber.js GitHub repository
50
- When I go to the README file
51
- Then I should see a "Build Status" badge
52
- And I should see a "Dependencies" badge
148
+ @QaseID=1,2,3
149
+ Scenario: Multiple test case coverage
150
+ Given I am on the login page
151
+ When I enter valid credentials
152
+ Then I should see the dashboard
53
153
  ```
54
154
 
55
- To execute Cucumber JS tests and report them to Qase.io, run the command:
155
+ > **Note:** Unlike other frameworks, CucumberJS uses Gherkin tags (`@QaseID=N`) instead of programmatic wrapper functions. Test case linking happens at the scenario level in feature files.
156
+
157
+ ### Add Metadata
158
+
159
+ Enhance your scenarios with additional information using tags:
160
+
161
+ **Using Gherkin Tags:**
162
+ ```gherkin
163
+ Feature: User Authentication
56
164
 
57
- ```bash
58
- QASE_MODE=testops cucumber-js -f cucumberjs-qase-reporter features -r step_definitions --publish-quiet
165
+ @QaseID=1
166
+ @QaseTitle=Custom Test Title
167
+ @QaseFields={"severity":"critical","priority":"high","layer":"e2e"}
168
+ Scenario: Login with metadata
169
+ Given I am on the login page
170
+ When I enter valid credentials
171
+ Then I should see the dashboard
59
172
  ```
60
173
 
61
- or
174
+ **Programmatic Metadata (in Before hooks):**
175
+ ```javascript
176
+ // support/hooks.js
177
+ const { Before } = require('@cucumber/cucumber');
62
178
 
63
- ```bash
64
- npm test
179
+ Before(function() {
180
+ // Note: programmatic metadata requires custom implementation
181
+ // Most metadata is set via Gherkin tags
182
+ });
65
183
  ```
66
184
 
67
- You can try it with the example project at [`examples/cucumberjs`](../examples/cucumberjs/).
185
+ ### Ignore Tests
68
186
 
69
- <p align="center">
70
- <img width="65%" src="./screenshots/screenshot.png">
71
- </p>
187
+ Exclude specific scenarios from Qase reporting (scenario still runs, but results are not sent):
72
188
 
73
- A test run will be performed and available at:
189
+ ```gherkin
190
+ Feature: User Authentication
74
191
 
75
- ```
76
- https://app.qase.io/run/QASE_PROJECT_CODE
192
+ @QaseIgnore
193
+ Scenario: Test not reported to Qase
194
+ Given I am on the login page
195
+ When I enter valid credentials
196
+ Then I should see the dashboard
77
197
  ```
78
198
 
79
- <p align="center">
80
- <img src="./screenshots/demo.gif">
81
- </p>
199
+ ### Test Result Statuses
82
200
 
83
- ### Multi-Project Support
201
+ | CucumberJS Result | Qase Status |
202
+ |-------------------|-------------|
203
+ | Passed | Passed |
204
+ | Failed | Failed |
205
+ | Pending | Blocked |
206
+ | Skipped | Skipped |
207
+ | Undefined | Blocked |
208
+ | Ambiguous | Failed |
84
209
 
85
- Qase CucumberJS Reporter supports sending test results to multiple Qase projects simultaneously. Use tags in feature files: `@qaseid.PROJ1(1) @qaseid.PROJ2(2)`.
210
+ > For more usage examples, see the [Usage Guide](docs/usage.md).
86
211
 
87
- For detailed information, configuration, and examples, see the [Multi-Project Support Guide](docs/MULTI_PROJECT.md).
212
+ ## Running Tests
88
213
 
89
- ## Configuration
214
+ **Basic test execution with reporter:**
215
+ ```sh
216
+ QASE_MODE=testops npx cucumber-js -f cucumberjs-qase-reporter
217
+ ```
218
+
219
+ **With specific features:**
220
+ ```sh
221
+ QASE_MODE=testops npx cucumber-js -f cucumberjs-qase-reporter features/login.feature
222
+ ```
223
+
224
+ **With tags filtering:**
225
+ ```sh
226
+ npx cucumber-js -f cucumberjs-qase-reporter --tags "@smoke and not @skip"
227
+ ```
228
+
229
+ **Using cucumber.js profile:**
230
+ ```sh
231
+ npx cucumber-js --profile default
232
+ ```
90
233
 
91
- Qase Cucumber JS reporter can be configured in multiple ways:
234
+ > **Note:** The reporter formatter should be specified with `-f cucumberjs-qase-reporter` flag or in your cucumber.js configuration.
92
235
 
93
- - using a separate config file `qase.config.json`,
94
- - using environment variables (they override the values from the configuration files).
236
+ ## Network Profiler
95
237
 
96
- For a full list of configuration options, see
97
- the [Configuration reference](../qase-javascript-commons/README.md#configuration).
238
+ The Network Profiler automatically captures outgoing HTTP requests made during test execution and reports them as REQUEST-type steps in Qase TestOps.
98
239
 
99
- Example `qase.config.json` file:
240
+ **Enable in `qase.config.json`:**
100
241
 
101
242
  ```json
102
243
  {
103
- "mode": "testops",
104
- "debug": true,
105
- "testops": {
106
- "api": {
107
- "token": "api_key"
108
- },
109
- "project": "project_code",
110
- "run": {
111
- "complete": true
112
- }
244
+ "profilers": ["network"],
245
+ "networkProfiler": {
246
+ "skip_domains": ["analytics.example.com"],
247
+ "track_on_fail": true
113
248
  }
114
249
  }
115
250
  ```
116
251
 
117
- Supported ENV variables:
252
+ | Option | Description | Default |
253
+ |--------|-------------|---------|
254
+ | `profilers` | Array of profilers to enable. Use `["network"]` for HTTP capture | `[]` |
255
+ | `networkProfiler.skip_domains` | Domains to exclude from profiling | `[]` |
256
+ | `networkProfiler.track_on_fail` | Capture response body for failed requests (status >= 400) | `true` |
118
257
 
119
- - `QASE_MODE` - Same as `mode`
120
- - `QASE_DEBUG` - Same as `debug`
121
- - `QASE_ENVIRONMENT` - Same as `environment`
122
- - `QASE_TESTOPS_API_TOKEN` - Same as `testops.api.token`
123
- - `QASE_TESTOPS_PROJECT` - Same as `testops.project`
124
- - `QASE_TESTOPS_RUN_ID` - Pass Run ID from ENV and override reporter option `testops.run.id`
125
- - `QASE_TESTOPS_RUN_TITLE` - Same as `testops.run.title`
126
- - `QASE_TESTOPS_RUN_DESCRIPTION` - Same as `testops.run.description`
258
+ > Requests to `qase.io` are always excluded automatically.
127
259
 
128
- To run using ENV you have to execute:
260
+ ## Requirements
129
261
 
130
- ```bash
131
- cucumber-js -f cucumberjs-qase-reporter features -r step_definitions --publish-quiet
132
- ```
262
+ - Node.js >= 14
263
+ - @cucumber/cucumber >= 8.0.0
133
264
 
134
- ## Requirements
265
+ ## Documentation
266
+
267
+ | Guide | Description |
268
+ |-------|-------------|
269
+ | [Usage Guide](docs/usage.md) | Complete usage reference with all tags and patterns |
270
+ | [Attachments](docs/ATTACHMENTS.md) | Adding screenshots, logs, and files to test results |
271
+ | [Steps](docs/STEPS.md) | Understanding native Gherkin step mapping |
272
+ | [Multi-Project Support](docs/MULTI_PROJECT.md) | Reporting to multiple Qase projects |
273
+ | [Upgrade Guide](docs/UPGRADE.md) | Migration guide for breaking changes |
135
274
 
136
- We maintain the reporter on [LTS versions of Node](https://nodejs.org/en/about/releases/).
275
+ ## Examples
137
276
 
138
- `@cucumber/cucumber >= 7.0.0`
277
+ See the [examples directory](../examples/) for complete working examples.
139
278
 
140
- <!-- references -->
279
+ ## License
141
280
 
142
- [auth]: https://developers.qase.io/#authentication
281
+ Apache License 2.0. See [LICENSE](LICENSE) for details.
package/changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ # qase-cucumberjs@2.2.1
2
+
3
+ ## What's new
4
+
5
+ - Added Network Profiler integration for automatic HTTP request capture during test execution.
6
+ - Updated `qase-javascript-commons` dependency to `~2.5.6`.
7
+
1
8
  # qase-cucumberjs@2.2.0
2
9
 
3
10
  ## What's new
@@ -18,6 +18,11 @@ export declare class CucumberQaseReporter extends Formatter {
18
18
  * @private
19
19
  */
20
20
  private reporter;
21
+ /**
22
+ * @type {NetworkProfiler | null}
23
+ * @private
24
+ */
25
+ private profiler;
21
26
  /**
22
27
  * @type {EventEmitter}
23
28
  * @private
package/dist/reporter.js CHANGED
@@ -19,6 +19,11 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
19
19
  * @private
20
20
  */
21
21
  reporter;
22
+ /**
23
+ * @type {NetworkProfiler | null}
24
+ * @private
25
+ */
26
+ profiler = null;
22
27
  /**
23
28
  * @type {EventEmitter}
24
29
  * @private
@@ -32,14 +37,22 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
32
37
  const { qase, ...formatterOptions } = options;
33
38
  const config = configLoader.load();
34
39
  super(formatterOptions);
40
+ const composedOptions = (0, qase_javascript_commons_1.composeOptions)(qase, config);
35
41
  this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
36
- ...(0, qase_javascript_commons_1.composeOptions)(qase, config),
42
+ ...composedOptions,
37
43
  frameworkPackage: '@cucumber/cucumber',
38
44
  frameworkName: 'cucumberjs',
39
45
  reporterName: 'cucumberjs-qase-reporter',
40
46
  });
47
+ if (composedOptions.profilers?.includes('network')) {
48
+ this.profiler = new qase_javascript_commons_1.NetworkProfiler({
49
+ skipDomains: composedOptions.networkProfiler?.skip_domains,
50
+ trackOnFail: composedOptions.networkProfiler?.track_on_fail,
51
+ });
52
+ this.profiler.enable();
53
+ }
41
54
  this.eventBroadcaster = formatterOptions.eventBroadcaster;
42
- this.storage = new storage_1.Storage();
55
+ this.storage = new storage_1.Storage(this.profiler);
43
56
  this.bindEventListeners();
44
57
  }
45
58
  /**
@@ -85,6 +98,7 @@ class CucumberQaseReporter extends cucumber_1.Formatter {
85
98
  * @private
86
99
  */
87
100
  async publishResults() {
101
+ this.profiler?.restore();
88
102
  await this.reporter.publish();
89
103
  }
90
104
  /**
package/dist/storage.d.ts CHANGED
@@ -1,9 +1,20 @@
1
1
  import { Attachment as Attach, GherkinDocument, Pickle, TestCaseFinished, TestCaseStarted, TestStepFinished } from '@cucumber/messages';
2
- import { StepStatusEnum, TestResultType, TestStatusEnum } from 'qase-javascript-commons';
2
+ import { NetworkProfiler, StepStatusEnum, TestResultType, TestStatusEnum } from 'qase-javascript-commons';
3
3
  import { TestCase } from '@cucumber/messages/dist/esm/src/messages';
4
4
  import { Status } from '@cucumber/cucumber';
5
5
  type TestStepResultStatus = (typeof Status)[keyof typeof Status];
6
6
  export declare class Storage {
7
+ /**
8
+ * @type {NetworkProfiler | null}
9
+ * @private
10
+ */
11
+ private profiler;
12
+ /**
13
+ * @type {Record<string, number>}
14
+ * @private
15
+ */
16
+ private profilerStepSnapshots;
17
+ constructor(profiler?: NetworkProfiler | null);
7
18
  /**
8
19
  * @type {Record<string, Pickle>}
9
20
  * @private
package/dist/storage.js CHANGED
@@ -13,6 +13,19 @@ const qaseGroupParametersRegExp = /^@[Qq]ase[Gg]roup[Pp]arameters=(.+)$/;
13
13
  const qaseSuiteRegExp = /^@[Qq]ase[Ss]uite=(.+)$/;
14
14
  const qaseIgnoreRegExp = /^@[Qq]ase[Ii][Gg][Nn][Oo][Rr][Ee]$/;
15
15
  class Storage {
16
+ /**
17
+ * @type {NetworkProfiler | null}
18
+ * @private
19
+ */
20
+ profiler;
21
+ /**
22
+ * @type {Record<string, number>}
23
+ * @private
24
+ */
25
+ profilerStepSnapshots = {};
26
+ constructor(profiler = null) {
27
+ this.profiler = profiler;
28
+ }
16
29
  /**
17
30
  * @type {Record<string, Pickle>}
18
31
  * @private
@@ -141,6 +154,9 @@ class Storage {
141
154
  testCaseStarted;
142
155
  this.testCaseStartedResult[testCaseStarted.id] =
143
156
  qase_javascript_commons_1.TestStatusEnum.passed;
157
+ if (this.profiler) {
158
+ this.profilerStepSnapshots[testCaseStarted.id] = this.profiler.getAllSteps().length;
159
+ }
144
160
  }
145
161
  /**
146
162
  * Add test case step to storage
@@ -236,6 +252,14 @@ class Storage {
236
252
  // Parameters from tags take precedence over Gherkin examples
237
253
  params = { ...params, ...metadata.parameters };
238
254
  const steps = this.convertSteps(pickle.steps, tc);
255
+ // Collect profiler steps since this test case started
256
+ let profilerSteps = [];
257
+ if (this.profiler) {
258
+ const snapshot = this.profilerStepSnapshots[testCase.testCaseStartedId] ?? 0;
259
+ const allSteps = this.profiler.getAllSteps();
260
+ profilerSteps = allSteps.slice(snapshot);
261
+ delete this.profilerStepSnapshots[testCase.testCaseStartedId];
262
+ }
239
263
  const hasProjectMapping = Object.keys(metadata.projectMapping).length > 0;
240
264
  const result = {
241
265
  attachments: this.attachments[testCase.testCaseStartedId] ?? [],
@@ -256,7 +280,7 @@ class Storage {
256
280
  relations: relations,
257
281
  run_id: null,
258
282
  signature: this.getSignature(pickle, metadata.ids, params),
259
- steps: steps,
283
+ steps: [...steps, ...profilerSteps],
260
284
  testops_id: metadata.ids.length > 0 ? metadata.ids : null,
261
285
  testops_project_mapping: hasProjectMapping ? metadata.projectMapping : null,
262
286
  id: tcs.id,