mocha-qase-reporter 1.1.1 → 1.1.2

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 (3) hide show
  1. package/README.md +4 -2
  2. package/docs/usage.md +296 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -20,6 +20,8 @@ from Qase.io before executing tests. It's a more reliable way to bind
20
20
  autotests to test cases, that persists when you rename, move, or
21
21
  parameterize your tests.
22
22
 
23
+ For more information, see the [Usage Guide](docs/usage.md).
24
+
23
25
  For example:
24
26
 
25
27
  ```typescript
@@ -74,7 +76,7 @@ the [Qase CLI](https://github.com/qase-tms/qasectl):
74
76
 
75
77
  ```bash
76
78
  # Create a new test run
77
- qli testops run create --project DEMO --token token --title 'Mocha test run'
79
+ qasectl testops run create --project DEMO --token token --title 'Mocha test run'
78
80
 
79
81
  # Save the run ID to the environment variable
80
82
  export QASE_TESTOPS_RUN_ID=$(< qase.env grep QASE_TESTOPS_RUN_ID | cut -d'=' -f2)
@@ -89,7 +91,7 @@ QASE_MODE=testops mocha --parallel
89
91
  After the tests are finished, you can complete the run:
90
92
 
91
93
  ```bash
92
- qli testops run complete --project DEMO --token token --id $(echo $QASE_TESTOPS_RUN_ID)
94
+ qasectl testops run complete --project DEMO --token token --id $(echo $QASE_TESTOPS_RUN_ID)
93
95
  ```
94
96
 
95
97
  ## Configuration
package/docs/usage.md ADDED
@@ -0,0 +1,296 @@
1
+ # Qase Integration in Mocha
2
+
3
+ This guide demonstrates how to integrate Qase with Mocha, providing instructions on how to add Qase IDs, titles,
4
+ fields, suites, comments, and file attachments to your test cases.
5
+
6
+ ---
7
+
8
+ ## Adding QaseID to a Test
9
+
10
+ To associate a QaseID with a test in Mocha, use the `qase()` function. This function accepts a single integer or
11
+ an array of integers representing the test's ID(s) in Qase, and optionally a custom test name.
12
+
13
+ ### Example
14
+
15
+ ```javascript
16
+ const { qase } = require('mocha-qase-reporter/mocha');
17
+
18
+ describe('User Authentication', function() {
19
+ it(qase(1, 'Successful login'), function() {
20
+ expect(true).to.equal(true);
21
+ });
22
+
23
+ it(qase([2, 3, 4], 'Multiple test cases'), function() {
24
+ expect(true).to.equal(true);
25
+ });
26
+ });
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Adding a Title to a Test
32
+
33
+ You can provide a custom title for your test using the `this.title()` method within the test function.
34
+ If no title is provided, the test's default name will be used.
35
+
36
+ ### Example
37
+
38
+ ```javascript
39
+ const { qase } = require('mocha-qase-reporter/mocha');
40
+
41
+ describe('User Authentication', function() {
42
+ it('test with custom title', function() {
43
+ this.title('Custom Test Title');
44
+ expect(true).to.equal(true);
45
+ });
46
+
47
+ it('test with default title', function() {
48
+ expect(true).to.equal(true);
49
+ });
50
+ });
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Adding Fields to a Test
56
+
57
+ You can add additional metadata to a test case using the `this.fields()` method. This allows you
58
+ to specify multiple fields to enhance test case information in Qase.
59
+
60
+ ### System Fields
61
+
62
+ - `description` — Description of the test case.
63
+ - `preconditions` — Preconditions for the test case.
64
+ - `postconditions` — Postconditions for the test case.
65
+ - `severity` — Severity of the test case (e.g., `critical`, `major`).
66
+ - `priority` — Priority of the test case (e.g., `high`, `low`).
67
+ - `layer` — Test layer (e.g., `UI`, `API`).
68
+
69
+ ### Example
70
+
71
+ ```javascript
72
+ const { qase } = require('mocha-qase-reporter/mocha');
73
+
74
+ describe('User Authentication', function() {
75
+ it('test with fields', function() {
76
+ this.fields({
77
+ severity: 'high',
78
+ priority: 'medium',
79
+ description: 'Login functionality test',
80
+ custom_field: 'value'
81
+ });
82
+ expect(true).to.equal(true);
83
+ });
84
+ });
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Adding a Suite to a Test
90
+
91
+ To assign a suite or sub-suite to a test, use the `this.suite()` method. It can receive a suite
92
+ name, and optionally a sub-suite, both as strings.
93
+
94
+ ### Example
95
+
96
+ ```javascript
97
+ const { qase } = require('mocha-qase-reporter/mocha');
98
+
99
+ describe('User Authentication', function() {
100
+ it('test with suite', function() {
101
+ this.suite('Authentication');
102
+ expect(true).to.equal(true);
103
+ });
104
+
105
+ it('test with nested suite', function() {
106
+ this.suite('Authentication\\Login\\Edge Cases');
107
+ expect(true).to.equal(true);
108
+ });
109
+ });
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Ignoring a Test in Qase
115
+
116
+ To exclude a test from being reported to Qase (while still executing the test in Mocha), use the `this.ignore()`
117
+ method. The test will run, but its result will not be sent to Qase.
118
+
119
+ ### Example
120
+
121
+ ```javascript
122
+ const { qase } = require('mocha-qase-reporter/mocha');
123
+
124
+ describe('User Authentication', function() {
125
+ it('ignored test', function() {
126
+ this.ignore();
127
+ expect(true).to.equal(true);
128
+ });
129
+ });
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Adding Parameters to a Test
135
+
136
+ You can add parameters to a test case using the `this.parameters()` method. This method accepts
137
+ an object with parameter names and values.
138
+
139
+ ### Example
140
+
141
+ ```javascript
142
+ const { qase } = require('mocha-qase-reporter/mocha');
143
+
144
+ describe('User Authentication', function() {
145
+ it('test with parameters', function() {
146
+ this.parameters({
147
+ browser: 'chrome',
148
+ environment: 'staging'
149
+ });
150
+ expect(true).to.equal(true);
151
+ });
152
+ });
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Adding Group Parameters to a Test
158
+
159
+ To add group parameters to a test case, use the `this.groupParameters()` method. This method
160
+ accepts an object with group parameter names and values.
161
+
162
+ ### Example
163
+
164
+ ```javascript
165
+ const { qase } = require('mocha-qase-reporter/mocha');
166
+
167
+ describe('User Authentication', function() {
168
+ it('test with group parameters', function() {
169
+ this.parameters({
170
+ browser: 'chrome',
171
+ environment: 'staging'
172
+ });
173
+ this.groupParameters({
174
+ test_group: 'authentication',
175
+ test_type: 'smoke'
176
+ });
177
+ expect(true).to.equal(true);
178
+ });
179
+ });
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Adding Steps to a Test
185
+
186
+ You can add custom steps to your test cases using the `this.step()` method. Each step should
187
+ have a title and optionally a function.
188
+
189
+ ### Example
190
+
191
+ ```javascript
192
+ const { qase } = require('mocha-qase-reporter/mocha');
193
+
194
+ describe('User Authentication', function() {
195
+ it('test with steps', function() {
196
+ this.step('Navigate to login page', function() {
197
+ // Step implementation
198
+ });
199
+ this.step('Enter credentials', function() {
200
+ // Step implementation
201
+ });
202
+ this.step('Submit login form', function() {
203
+ // Step implementation
204
+ });
205
+ this.step('Verify successful login', function() {
206
+ // Step implementation
207
+ });
208
+ expect(true).to.equal(true);
209
+ });
210
+ });
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Attaching Files to a Test
216
+
217
+ You can attach files to test results using the `this.attach()` method. This method supports attaching files
218
+ with content, paths, or media types.
219
+
220
+ ### Example
221
+
222
+ ```javascript
223
+ const { qase } = require('mocha-qase-reporter/mocha');
224
+
225
+ describe('User Authentication', function() {
226
+ it('test with attachments', function() {
227
+ // Attach text content
228
+ this.attach({
229
+ name: 'attachment.log',
230
+ content: 'Login successful',
231
+ contentType: 'text/plain'
232
+ });
233
+
234
+ // Attach JSON data
235
+ const userData = { username: 'testuser', status: 'logged_in' };
236
+ this.attach({
237
+ name: 'user-data.json',
238
+ content: JSON.stringify(userData, null, 2),
239
+ contentType: 'application/json'
240
+ });
241
+
242
+ expect(true).to.equal(true);
243
+ });
244
+ });
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Adding Comments to a Test
250
+
251
+ You can add comments to test results using the `this.comment()` method. This is useful for providing additional
252
+ context or explanations about test execution.
253
+
254
+ ### Example
255
+
256
+ ```javascript
257
+ const { qase } = require('mocha-qase-reporter/mocha');
258
+
259
+ describe('User Authentication', function() {
260
+ it('test with comments', function() {
261
+ // Add comment about the test execution
262
+ this.comment('Login test completed successfully');
263
+
264
+ // Add comment with additional context
265
+ this.comment('User was redirected to dashboard as expected');
266
+
267
+ expect(true).to.equal(true);
268
+ });
269
+ });
270
+ ```
271
+
272
+ ---
273
+
274
+ ### Parallel Execution
275
+
276
+ The reporter supports parallel execution of tests. First, create a new run in Qase.io using the Qase CLI:
277
+
278
+ ```bash
279
+ # Create a new test run
280
+ qasectl testops run create --project DEMO --token token --title 'Mocha test run'
281
+
282
+ # Save the run ID to the environment variable
283
+ export QASE_TESTOPS_RUN_ID=$(< qase.env grep QASE_TESTOPS_RUN_ID | cut -d'=' -f2)
284
+ ```
285
+
286
+ Then run tests in parallel:
287
+
288
+ ```bash
289
+ QASE_MODE=testops mocha --parallel
290
+ ```
291
+
292
+ After the tests are finished, complete the run:
293
+
294
+ ```bash
295
+ qasectl testops run complete --project DEMO --token token --id $(echo $QASE_TESTOPS_RUN_ID)
296
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha-qase-reporter",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Mocha Cypress Reporter",
5
5
  "homepage": "https://github.com/qase-tms/qase-javascript",
6
6
  "sideEffects": false,
@@ -43,7 +43,7 @@
43
43
  "dependencies": {
44
44
  "mocha": "^10.2.0",
45
45
  "deasync-promise": "^1.0.1",
46
- "qase-javascript-commons": "~2.3.3",
46
+ "qase-javascript-commons": "~2.4.1",
47
47
  "uuid": "^9.0.1"
48
48
  },
49
49
  "devDependencies": {