jest-qase-reporter 2.0.3 → 2.0.4
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 +2 -3
- package/changelog.md +6 -0
- package/dist/global.js +1 -0
- package/dist/reporter.d.ts +6 -0
- package/dist/reporter.js +39 -17
- package/dist/step.js +3 -3
- package/docs/usage.md +209 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -142,9 +142,8 @@ Reporter options (* - required):
|
|
|
142
142
|
- `mode` - `testops`/`off` Enables reporter, default - `off`
|
|
143
143
|
- `debug` - Enables debug logging, default - `false`
|
|
144
144
|
- `environment` - To execute with the sending of the envinroment information
|
|
145
|
-
- *`testops.api.token` - Token for API access, you can
|
|
146
|
-
|
|
147
|
-
- *`testops.project` - Qase project code, for example, in https://app.qase.io/project/DEMO the code is `DEMO`
|
|
145
|
+
- *`testops.api.token` - Token for API access, you can generate it [here](https://developers.qase.io/#authentication).
|
|
146
|
+
- *`testops.project` - [Your project's code](https://help.qase.io/en/articles/9787250-how-do-i-find-my-project-code)
|
|
148
147
|
- `testops.run.id` - Qase test run ID, used when the test run was created earlier using CLI or API call.
|
|
149
148
|
- `testops.run.title` - Set custom Run name, when new run is created
|
|
150
149
|
- `testops.run.description` - Set custom Run description, when new run is created
|
package/changelog.md
CHANGED
package/dist/global.js
CHANGED
package/dist/reporter.d.ts
CHANGED
package/dist/reporter.js
CHANGED
|
@@ -14,6 +14,22 @@ const global_1 = require("./global");
|
|
|
14
14
|
* @implements Reporter
|
|
15
15
|
*/
|
|
16
16
|
class JestQaseReporter {
|
|
17
|
+
/**
|
|
18
|
+
* @type {Record<Status, TestStatusEnum>}
|
|
19
|
+
*/
|
|
20
|
+
static statusMap = {
|
|
21
|
+
passed: qase_javascript_commons_1.TestStatusEnum.passed,
|
|
22
|
+
failed: qase_javascript_commons_1.TestStatusEnum.failed,
|
|
23
|
+
skipped: qase_javascript_commons_1.TestStatusEnum.skipped,
|
|
24
|
+
disabled: qase_javascript_commons_1.TestStatusEnum.disabled,
|
|
25
|
+
pending: qase_javascript_commons_1.TestStatusEnum.skipped,
|
|
26
|
+
todo: qase_javascript_commons_1.TestStatusEnum.disabled,
|
|
27
|
+
focused: qase_javascript_commons_1.TestStatusEnum.passed,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @type {RegExp}
|
|
31
|
+
*/
|
|
32
|
+
static qaseIdRegExp = /\(Qase ID: ([\d,]+)\)/;
|
|
17
33
|
/**
|
|
18
34
|
* @param {string} title
|
|
19
35
|
* @returns {number[]}
|
|
@@ -23,6 +39,16 @@ class JestQaseReporter {
|
|
|
23
39
|
const [, ids] = title.match(JestQaseReporter.qaseIdRegExp) ?? [];
|
|
24
40
|
return ids ? ids.split(',').map((id) => Number(id)) : [];
|
|
25
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* @type {ReporterInterface}
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
reporter;
|
|
47
|
+
/**
|
|
48
|
+
* @type {Metadata}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
metadata;
|
|
26
52
|
/**
|
|
27
53
|
* @param {Config.GlobalConfig} _
|
|
28
54
|
* @param {JestQaseOptionsType} options
|
|
@@ -230,7 +256,7 @@ class JestQaseReporter {
|
|
|
230
256
|
steps: [],
|
|
231
257
|
testops_id: ids.length > 0 ? ids : null,
|
|
232
258
|
id: (0, uuid_1.v4)(),
|
|
233
|
-
title: value.title,
|
|
259
|
+
title: this.removeQaseIdsFromTitle(value.title),
|
|
234
260
|
};
|
|
235
261
|
}
|
|
236
262
|
/**
|
|
@@ -250,21 +276,17 @@ class JestQaseReporter {
|
|
|
250
276
|
attachments: [],
|
|
251
277
|
};
|
|
252
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* @param {string} title
|
|
281
|
+
* @returns {string}
|
|
282
|
+
* @private
|
|
283
|
+
*/
|
|
284
|
+
removeQaseIdsFromTitle(title) {
|
|
285
|
+
const matches = title.match(/\(Qase ID: ([0-9,]+)\)$/i);
|
|
286
|
+
if (matches) {
|
|
287
|
+
return title.replace(matches[0], '').trimEnd();
|
|
288
|
+
}
|
|
289
|
+
return title;
|
|
290
|
+
}
|
|
253
291
|
}
|
|
254
292
|
exports.JestQaseReporter = JestQaseReporter;
|
|
255
|
-
/**
|
|
256
|
-
* @type {Record<Status, TestStatusEnum>}
|
|
257
|
-
*/
|
|
258
|
-
JestQaseReporter.statusMap = {
|
|
259
|
-
passed: qase_javascript_commons_1.TestStatusEnum.passed,
|
|
260
|
-
failed: qase_javascript_commons_1.TestStatusEnum.failed,
|
|
261
|
-
skipped: qase_javascript_commons_1.TestStatusEnum.skipped,
|
|
262
|
-
disabled: qase_javascript_commons_1.TestStatusEnum.disabled,
|
|
263
|
-
pending: qase_javascript_commons_1.TestStatusEnum.skipped,
|
|
264
|
-
todo: qase_javascript_commons_1.TestStatusEnum.disabled,
|
|
265
|
-
focused: qase_javascript_commons_1.TestStatusEnum.passed,
|
|
266
|
-
};
|
|
267
|
-
/**
|
|
268
|
-
* @type {RegExp}
|
|
269
|
-
*/
|
|
270
|
-
JestQaseReporter.qaseIdRegExp = /\(Qase ID: ([\d,]+)\)/;
|
package/dist/step.js
CHANGED
|
@@ -9,10 +9,10 @@ const uuid_1 = require("uuid");
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
// TODO: Move to common, because it's duplicated in qase-wdio/src/step.ts
|
|
11
11
|
class QaseStep {
|
|
12
|
+
name = '';
|
|
13
|
+
attachments = [];
|
|
14
|
+
steps = [];
|
|
12
15
|
constructor(name) {
|
|
13
|
-
this.name = '';
|
|
14
|
-
this.attachments = [];
|
|
15
|
-
this.steps = [];
|
|
16
16
|
this.name = name;
|
|
17
17
|
}
|
|
18
18
|
attach(attach) {
|
package/docs/usage.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Qase Syntax
|
|
2
|
+
|
|
3
|
+
> [**Click here**](../../examples/jest/test) to view Example tests for the following syntax.
|
|
4
|
+
|
|
5
|
+
Here is the complete list of syntax options available for the reporter:
|
|
6
|
+
- [Qase Id](#qase-id)
|
|
7
|
+
- [Qase Title](#qase-title)
|
|
8
|
+
- [Steps](#steps)
|
|
9
|
+
- [Fields](#fields)
|
|
10
|
+
- [Suite](#suite)
|
|
11
|
+
- [Parameters](#parameters)
|
|
12
|
+
- [Comment](#comment)
|
|
13
|
+
- [Attach](#attach)
|
|
14
|
+
- [Ignore](#ignore)
|
|
15
|
+
|
|
16
|
+
If you do not use any Qase syntax, the reporter uses the title from the `describe` and `test` functions as the Suite and Test case title respectively, when publishing results.
|
|
17
|
+
|
|
18
|
+
<br>
|
|
19
|
+
|
|
20
|
+
### Import Statement
|
|
21
|
+
---
|
|
22
|
+
Add the following statement at the beginning of your spec file, before any tests.
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
const { qase } = require("jest-qase-reporter/jest");
|
|
26
|
+
```
|
|
27
|
+
<br>
|
|
28
|
+
|
|
29
|
+
### Qase ID
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
You can link one or more Qase Ids to a test.
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
test(qase(1, "A test with Qase Id"), () => {
|
|
36
|
+
..
|
|
37
|
+
|
|
38
|
+
test(qase(['2', '3'], "A test with multiple Qase Ids"), () => {
|
|
39
|
+
..
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
<br>
|
|
43
|
+
|
|
44
|
+
### Qase Title
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
The `qase.title()` method is used to set the title of a test case, both when creating a new test case from the result, and when updating the title of an existing test case - *if used with `qase.id()`.*
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
test("This won't appear in Qase", () => {
|
|
51
|
+
qase.title("This text will be the title of the test, in Qase");
|
|
52
|
+
// Test logic here
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If you don’t explicitly set a title using this method, the title specified in the `test(..)` function will be used for creating new test cases. However, if this method is defined, it always takes precedence and overrides the title from the `test(..)` function.
|
|
57
|
+
|
|
58
|
+
<br>
|
|
59
|
+
|
|
60
|
+
### Steps
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
The reporter uses the title from the `test.step` function as the step title. By providing clear and descriptive step names, you make it easier to understand the test’s flow when reviewing the test case.
|
|
64
|
+
|
|
65
|
+
Additionally, these steps get their own result in the Qase Test run, offering a well-organized summary of the test flow. This helps quickly identify the cause of any failures.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
test('A Test case with steps, updated from code', async () => {
|
|
69
|
+
await test.step('Initialize the environment', async () => {
|
|
70
|
+
// Set up test environment
|
|
71
|
+
});
|
|
72
|
+
await test.step('Test Core Functionality of the app', async () => {
|
|
73
|
+
// Exercise core functionality
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await test.step('Verify Expected Behavior of the app', async () => {
|
|
77
|
+
// Assert expected behavior
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
<br>
|
|
82
|
+
|
|
83
|
+
### Fields
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
You can define the `description`, `pre-conditions`, `post-conditions`, and fields such as `severity`, `priority`, and `layer` using this method, which enables you to specify and maintain the context of the case directly within your code.
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
test('Maintain your test meta-data from code', async () => {
|
|
90
|
+
await qase.fields({
|
|
91
|
+
severity: 'high',
|
|
92
|
+
priority: 'medium',
|
|
93
|
+
layer: 'api',
|
|
94
|
+
precondition: 'add your precondition',
|
|
95
|
+
postcondition: 'add your postcondition',
|
|
96
|
+
description: `Code it quick, fix it slow,
|
|
97
|
+
Tech debt grows where shortcuts go,
|
|
98
|
+
Refactor later? Ha! We know.`
|
|
99
|
+
});
|
|
100
|
+
// test logic here
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
<br>
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### Suite
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
You can use this method to nest the resulting test cases in a particular suite. There's something to note here – suites, unlike test cases, are not identified uniquely by the Reporter. Therefore, when defining an existing suite - the title of the suite is used for matching.
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
test("Test with a defined suite", () => {
|
|
114
|
+
qase.suite("Suite defined with qase.suite()");
|
|
115
|
+
/*
|
|
116
|
+
* Or, nest multiple levels of suites.
|
|
117
|
+
* `\t` is used for dividing each suite name.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
test("Test with a nested suite", () => {
|
|
121
|
+
qase.suite("Application\tAuthentication\tLogin\tEdge_case");
|
|
122
|
+
// test logic here
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
<br>
|
|
126
|
+
|
|
127
|
+
### Parameters
|
|
128
|
+
---
|
|
129
|
+
Parameters are a great way to make your tests more dynamic, reusable, and data-driven. By defining parameters in this method, you can ensure only one test case with all the parameters is created in your Qase project, avoiding duplication.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
```javascript
|
|
133
|
+
const testCases = [
|
|
134
|
+
{ browser: "Chromium", username: "@alice", password: "123" },
|
|
135
|
+
{ browser: "Firefox", username: "@bob", password: "456" },
|
|
136
|
+
{ browser: "Webkit", username: "@charlie", password: "789" },
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
testCases.forEach(({ browser, username, password, }) => {
|
|
140
|
+
test(`Test login with ${browser}`, async () => {
|
|
141
|
+
qase.title("Verify if page loads on all browsers");
|
|
142
|
+
|
|
143
|
+
qase.parameters({ Browser: browser }); // Single parameter
|
|
144
|
+
// test logic
|
|
145
|
+
|
|
146
|
+
testCases.forEach(({ username, password }) => {
|
|
147
|
+
test(`Test login with ${username} using qase.groupParameters`, () => {
|
|
148
|
+
qase.title("Verify if user is able to login with their username.");
|
|
149
|
+
|
|
150
|
+
qase.groupParameters({ // Group parameters
|
|
151
|
+
Username: username,
|
|
152
|
+
Password: password,
|
|
153
|
+
});
|
|
154
|
+
// test logic
|
|
155
|
+
```
|
|
156
|
+
<br>
|
|
157
|
+
|
|
158
|
+
### Comment
|
|
159
|
+
---
|
|
160
|
+
In addition to `test.step()`, this method can be used to provide any additional context to your test, it helps maintiain the code by clarifying the expected result of the test.
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
test("A test case with qase.comment()", () => {
|
|
164
|
+
/*
|
|
165
|
+
* Please note, this comment is added to a Result, not to the Test case.
|
|
166
|
+
*/
|
|
167
|
+
qase.comment("This comment is added to the result");
|
|
168
|
+
// test logic here
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
<br>
|
|
172
|
+
|
|
173
|
+
### Attach
|
|
174
|
+
---
|
|
175
|
+
This method can help attach one, or more files to the test's result. You can also add the file's contents directly from code. For example:
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
test('Test result with attachment', async () => {
|
|
179
|
+
|
|
180
|
+
test("Test result with attachment", async () => {
|
|
181
|
+
|
|
182
|
+
// To attach a single file
|
|
183
|
+
await qase.attach({
|
|
184
|
+
paths: "./attachments/test-file.txt",
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Add multiple attachments.
|
|
188
|
+
await qase.attach({ paths: ['/path/to/file', '/path/to/another/file'] });
|
|
189
|
+
|
|
190
|
+
// Upload file's contents directly from code.
|
|
191
|
+
await qase.attach({
|
|
192
|
+
name: "attachment.txt",
|
|
193
|
+
content: "Hello, world!",
|
|
194
|
+
contentType: "text/plain",
|
|
195
|
+
});
|
|
196
|
+
// test logic here
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
<br>
|
|
200
|
+
|
|
201
|
+
### Ignore
|
|
202
|
+
---
|
|
203
|
+
If this method is added, the reporter will exclude the test’s result from the report sent to Qase. While the test will still executed by jest, its result will not be considered by the reporter.
|
|
204
|
+
|
|
205
|
+
```js
|
|
206
|
+
test("This test is executed by jest; however, it is NOT reported to Qase", () => {
|
|
207
|
+
qase.ignore();
|
|
208
|
+
// test logic here
|
|
209
|
+
```
|