jest-qase-reporter 1.3.1 → 2.0.0-beta.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 +36 -27
- package/dist/index.d.ts +2 -39
- package/dist/index.js +2 -433
- package/dist/jest.d.ts +1 -4
- package/dist/jest.js +6 -13
- package/dist/reporter.d.ts +53 -0
- package/dist/reporter.js +98 -0
- package/package.json +42 -33
- package/tsconfig.build.json +9 -0
- package/dist/index.js.map +0 -1
- package/dist/jest.js.map +0 -1
- package/examples/package-lock.json +0 -3054
- package/examples/package.json +0 -17
- package/examples/test/arith.js +0 -6
- package/examples/test/arith.test.js +0 -75
- package/test/plugin.test.ts +0 -144
- /package/{examples/screenshots → screenshots}/screenshot.png +0 -0
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ But if necessary, you can independently register the ID of already
|
|
|
17
17
|
existing test cases from TMS before the executing tests. For example:
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import { qase } from 'jest-qase-reporter/
|
|
20
|
+
import { qase } from 'jest-qase-reporter/jest';
|
|
21
21
|
|
|
22
22
|
describe('My First Test', () => {
|
|
23
23
|
test(qase([1,2], 'Several ids'), () => {
|
|
@@ -39,7 +39,7 @@ describe('My First Test', () => {
|
|
|
39
39
|
```
|
|
40
40
|
To run tests and create a test run, execute the command (for example from folder examples):
|
|
41
41
|
```bash
|
|
42
|
-
|
|
42
|
+
QASE_MODE=testops npx jest
|
|
43
43
|
```
|
|
44
44
|
or
|
|
45
45
|
```bash
|
|
@@ -47,7 +47,7 @@ npm test
|
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
<p align="center">
|
|
50
|
-
<img width="65%" src="./
|
|
50
|
+
<img width="65%" src="./screenshots/screenshot.png">
|
|
51
51
|
</p>
|
|
52
52
|
|
|
53
53
|
A test run will be performed and available at:
|
|
@@ -60,15 +60,18 @@ https://app.qase.io/run/QASE_PROJECT_CODE
|
|
|
60
60
|
|
|
61
61
|
Reporter options (* - required):
|
|
62
62
|
|
|
63
|
-
-
|
|
63
|
+
- `mode` - `testops`/`off` Enables reporter, default - `off`
|
|
64
|
+
- `debug` - Enables debug logging, defaule - `false`
|
|
65
|
+
- `environment` - To execute with the sending of the envinroment information
|
|
66
|
+
- *`testops.api.token` - Token for API access, you can find more information
|
|
64
67
|
[here](https://developers.qase.io/#authentication)
|
|
65
|
-
- *`
|
|
66
|
-
page of your project: `https://app.qase.io/project/DEMOTR` -
|
|
68
|
+
- *`testops.project` - Code of your project (can be extracted from main
|
|
69
|
+
page of your project: `https://app.qase.io/project/DEMOTR` -
|
|
67
70
|
`DEMOTR` is project code here)
|
|
68
|
-
- `
|
|
69
|
-
- `
|
|
70
|
-
- `
|
|
71
|
-
- `
|
|
71
|
+
- `testops.run.id` - Pass Run ID
|
|
72
|
+
- `testops.run.title` - Set custom Run name, when new run is created
|
|
73
|
+
- `testops.run.description` - Set custom Run description, when new run is created
|
|
74
|
+
- `testops.run.complete` - Whether the run should be completed
|
|
72
75
|
|
|
73
76
|
Example `jest.config.js` config:
|
|
74
77
|
|
|
@@ -79,12 +82,18 @@ module.exports = {
|
|
|
79
82
|
[
|
|
80
83
|
'jest-qase-reporter',
|
|
81
84
|
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
debug: true,
|
|
86
|
+
environment: 1,
|
|
87
|
+
testops: {
|
|
88
|
+
api: {
|
|
89
|
+
token: 'api_key'
|
|
90
|
+
},
|
|
91
|
+
project: 'project_code',
|
|
92
|
+
run: {
|
|
93
|
+
id: 45,
|
|
94
|
+
complete: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
88
97
|
},
|
|
89
98
|
],
|
|
90
99
|
],
|
|
@@ -92,25 +101,25 @@ module.exports = {
|
|
|
92
101
|
};
|
|
93
102
|
```
|
|
94
103
|
|
|
95
|
-
You can check example configuration with multiple reporters in [example project](
|
|
104
|
+
You can check example configuration with multiple reporters in [example project](../examples/jest/jest.config.js).
|
|
96
105
|
|
|
97
106
|
Supported ENV variables:
|
|
98
107
|
|
|
99
|
-
- `
|
|
100
|
-
|
|
101
|
-
- `
|
|
102
|
-
- `
|
|
103
|
-
- `
|
|
104
|
-
- `
|
|
105
|
-
- `
|
|
106
|
-
- `
|
|
107
|
-
- `QASE_RUN_DESCRIPTION` - Set custom Run description, when new run is created
|
|
108
|
-
- `QASE_RUN_COMPLETE` - Complete run after all tests are finished
|
|
108
|
+
- `QASE_MODE` - Same as `mode`
|
|
109
|
+
- `QASE_DEBUG` - Same as `debug`
|
|
110
|
+
- `QASE_ENVIRONMENT` - Same as `environment`
|
|
111
|
+
- `QASE_TESTOPS_API_TOKEN` - Same as `testops.api.token`
|
|
112
|
+
- `QASE_TESTOPS_PROJECT` - Same as `testops.project`
|
|
113
|
+
- `QASE_TESTOPS_RUN_ID` - Pass Run ID from ENV and override reporter option `testops.run.id`
|
|
114
|
+
- `QASE_TESTOPS_RUN_TITLE` - Same as `testops.run.title`
|
|
115
|
+
- `QASE_TESTOPS_RUN_DESCRIPTION` - Same as `testops.run.description`
|
|
109
116
|
|
|
110
117
|
## Requirements
|
|
111
118
|
|
|
112
119
|
We maintain the reporter on LTS versions of Node. You can find the current versions by following the [link](https://nodejs.org/en/about/releases/)
|
|
113
120
|
|
|
121
|
+
`jest >= 28.0.0`
|
|
122
|
+
|
|
114
123
|
<!-- references -->
|
|
115
124
|
|
|
116
125
|
[auth]: https://developers.qase.io/#authentication
|
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
apiToken: string;
|
|
4
|
-
basePath?: string;
|
|
5
|
-
rootSuiteTitle?: string;
|
|
6
|
-
projectCode: string;
|
|
7
|
-
runId?: string;
|
|
8
|
-
runPrefix?: string;
|
|
9
|
-
logging?: boolean;
|
|
10
|
-
runComplete?: boolean;
|
|
11
|
-
environmentId?: number;
|
|
12
|
-
}
|
|
13
|
-
declare class QaseReporter implements Reporter {
|
|
14
|
-
private api;
|
|
15
|
-
private options;
|
|
16
|
-
private runId?;
|
|
17
|
-
private isDisabled;
|
|
18
|
-
private publishedResultsCount;
|
|
19
|
-
private preparedTestCases;
|
|
20
|
-
constructor(_: Record<string, unknown>, _options: QaseOptions);
|
|
21
|
-
onRunStart(): Promise<void>;
|
|
22
|
-
onTestResult(_test: Test, testResult: TestResult): Promise<void>;
|
|
23
|
-
onRunComplete(): Promise<void>;
|
|
24
|
-
getLastError(): void;
|
|
25
|
-
private log;
|
|
26
|
-
private getEnv;
|
|
27
|
-
private getCaseIds;
|
|
28
|
-
private logTestItem;
|
|
29
|
-
private createPreparedForPublishTestsArray;
|
|
30
|
-
private publishBulkTestResult;
|
|
31
|
-
private checkProject;
|
|
32
|
-
private createRunObject;
|
|
33
|
-
private createRun;
|
|
34
|
-
private checkRun;
|
|
35
|
-
private createResultCasesArray;
|
|
36
|
-
private createHeaders;
|
|
37
|
-
private getPackageVersion;
|
|
38
|
-
}
|
|
39
|
-
export = QaseReporter;
|
|
1
|
+
import { JestQaseReporter } from './reporter';
|
|
2
|
+
export = JestQaseReporter;
|
package/dist/index.js
CHANGED
|
@@ -1,434 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
54
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
55
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
56
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
57
|
-
r[k] = a[j];
|
|
58
|
-
return r;
|
|
59
|
-
};
|
|
60
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
61
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
|
-
};
|
|
63
|
-
var src_1 = require("qaseio/dist/src");
|
|
64
|
-
var qaseio_1 = require("qaseio");
|
|
65
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
66
|
-
var child_process_1 = require("child_process");
|
|
67
|
-
var fs_1 = require("fs");
|
|
68
|
-
var Envs;
|
|
69
|
-
(function (Envs) {
|
|
70
|
-
Envs["report"] = "QASE_REPORT";
|
|
71
|
-
Envs["apiToken"] = "QASE_API_TOKEN";
|
|
72
|
-
Envs["basePath"] = "QASE_API_BASE_URL";
|
|
73
|
-
Envs["projectCode"] = "QASE_PROJECT_CODE";
|
|
74
|
-
Envs["runId"] = "QASE_RUN_ID";
|
|
75
|
-
Envs["runName"] = "QASE_RUN_NAME";
|
|
76
|
-
Envs["runDescription"] = "QASE_RUN_DESCRIPTION";
|
|
77
|
-
Envs["runComplete"] = "QASE_RUN_COMPLETE";
|
|
78
|
-
Envs["environmentId"] = "QASE_ENVIRONMENT_ID";
|
|
79
|
-
Envs["rootSuiteTitle"] = "QASE_ROOT_SUITE_TITLE";
|
|
80
|
-
})(Envs || (Envs = {}));
|
|
81
|
-
var Statuses = {
|
|
82
|
-
passed: src_1.ResultCreateStatusEnum.PASSED,
|
|
83
|
-
failed: src_1.ResultCreateStatusEnum.FAILED,
|
|
84
|
-
skipped: src_1.ResultCreateStatusEnum.SKIPPED,
|
|
85
|
-
pending: src_1.ResultCreateStatusEnum.SKIPPED,
|
|
86
|
-
disabled: src_1.ResultCreateStatusEnum.BLOCKED,
|
|
87
|
-
};
|
|
88
|
-
var alwaysUndefined = function () { return undefined; };
|
|
89
|
-
var QaseReporter = /** @class */ (function () {
|
|
90
|
-
function QaseReporter(_, _options) {
|
|
91
|
-
this.isDisabled = false;
|
|
92
|
-
this.publishedResultsCount = 0;
|
|
93
|
-
this.options = _options;
|
|
94
|
-
this.options.projectCode = _options.projectCode || this.getEnv(Envs.projectCode) || '';
|
|
95
|
-
this.options.rootSuiteTitle = _options.rootSuiteTitle || this.getEnv(Envs.rootSuiteTitle);
|
|
96
|
-
this.options.runComplete = !!this.getEnv(Envs.runComplete) || this.options.runComplete;
|
|
97
|
-
this.api = new qaseio_1.QaseApi(this.getEnv(Envs.apiToken) || this.options.apiToken || '', this.getEnv(Envs.basePath) || this.options.basePath, this.createHeaders());
|
|
98
|
-
this.log(chalk_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{yellow Current PID: ", "}"], ["{yellow Current PID: ", "}"])), process.pid));
|
|
99
|
-
this.preparedTestCases = [];
|
|
100
|
-
if (!this.getEnv(Envs.report)) {
|
|
101
|
-
this.log(chalk_1.default(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{yellow QASE_REPORT env variable is not set. Reporting to qase.io is disabled.}"], ["{yellow QASE_REPORT env variable is not set. Reporting to qase.io is disabled.}"]))));
|
|
102
|
-
this.isDisabled = true;
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
QaseReporter.prototype.onRunStart = function () {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
var _this = this;
|
|
109
|
-
return __generator(this, function (_a) {
|
|
110
|
-
if (this.isDisabled) {
|
|
111
|
-
return [2 /*return*/];
|
|
112
|
-
}
|
|
113
|
-
return [2 /*return*/, this.checkProject(this.options.projectCode, function (prjExists) { return __awaiter(_this, void 0, void 0, function () {
|
|
114
|
-
var userDefinedRunId;
|
|
115
|
-
var _this = this;
|
|
116
|
-
return __generator(this, function (_a) {
|
|
117
|
-
if (!prjExists) {
|
|
118
|
-
this.log(chalk_1.default(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{red Project ", " does not exist}"], ["{red Project ", " does not exist}"])), this.options.projectCode));
|
|
119
|
-
this.isDisabled = true;
|
|
120
|
-
return [2 /*return*/];
|
|
121
|
-
}
|
|
122
|
-
this.log(chalk_1.default(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{green Project ", " exists}"], ["{green Project ", " exists}"])), this.options.projectCode));
|
|
123
|
-
userDefinedRunId = this.getEnv(Envs.runId) || this.options.runId;
|
|
124
|
-
if (userDefinedRunId) {
|
|
125
|
-
this.runId = userDefinedRunId;
|
|
126
|
-
return [2 /*return*/, this.checkRun(this.runId, function (runExists) {
|
|
127
|
-
if (runExists) {
|
|
128
|
-
_this.log(chalk_1.default(templateObject_5 || (templateObject_5 = __makeTemplateObject(["{green Using run ", " to publish test results}"], ["{green Using run ", " to publish test results}"])), _this.runId));
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
_this.log(chalk_1.default(templateObject_6 || (templateObject_6 = __makeTemplateObject(["{red Run ", " does not exist}"], ["{red Run ", " does not exist}"])), _this.runId));
|
|
132
|
-
_this.isDisabled = true;
|
|
133
|
-
}
|
|
134
|
-
})];
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return [2 /*return*/, this.createRun(this.getEnv(Envs.runName), this.getEnv(Envs.runDescription), function (created) {
|
|
138
|
-
var _a;
|
|
139
|
-
if (created) {
|
|
140
|
-
_this.runId = (_a = created.result) === null || _a === void 0 ? void 0 : _a.id;
|
|
141
|
-
process.env.QASE_RUN_ID = String(_this === null || _this === void 0 ? void 0 : _this.runId);
|
|
142
|
-
_this.log(chalk_1.default(templateObject_7 || (templateObject_7 = __makeTemplateObject(["{green Using run ", " to publish test results}"], ["{green Using run ", " to publish test results}"])), _this.runId));
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
_this.log(chalk_1.default(templateObject_8 || (templateObject_8 = __makeTemplateObject(["{red Could not create run in project ", "}"], ["{red Could not create run in project ", "}"])), _this.options.projectCode));
|
|
146
|
-
_this.isDisabled = true;
|
|
147
|
-
}
|
|
148
|
-
})];
|
|
149
|
-
}
|
|
150
|
-
return [2 /*return*/];
|
|
151
|
-
});
|
|
152
|
-
}); })];
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
QaseReporter.prototype.onTestResult = function (_test, testResult) {
|
|
157
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
return __generator(this, function (_a) {
|
|
159
|
-
switch (_a.label) {
|
|
160
|
-
case 0:
|
|
161
|
-
if (this.isDisabled) {
|
|
162
|
-
return [2 /*return*/];
|
|
163
|
-
}
|
|
164
|
-
this.preparedTestCases = this.createPreparedForPublishTestsArray(testResult.testResults);
|
|
165
|
-
return [4 /*yield*/, this.publishBulkTestResult().then(alwaysUndefined)];
|
|
166
|
-
case 1:
|
|
167
|
-
_a.sent();
|
|
168
|
-
return [2 /*return*/];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
QaseReporter.prototype.onRunComplete = function () {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
-
var err_1;
|
|
176
|
-
return __generator(this, function (_a) {
|
|
177
|
-
switch (_a.label) {
|
|
178
|
-
case 0:
|
|
179
|
-
if (this.isDisabled) {
|
|
180
|
-
return [2 /*return*/];
|
|
181
|
-
}
|
|
182
|
-
if (this.publishedResultsCount === 0) {
|
|
183
|
-
this.log('No testcases were matched. Ensure that your tests are declared correctly.');
|
|
184
|
-
return [2 /*return*/];
|
|
185
|
-
}
|
|
186
|
-
if (!this.options.runComplete) {
|
|
187
|
-
return [2 /*return*/];
|
|
188
|
-
}
|
|
189
|
-
_a.label = 1;
|
|
190
|
-
case 1:
|
|
191
|
-
_a.trys.push([1, 3, , 4]);
|
|
192
|
-
return [4 /*yield*/, this.api.runs.completeRun(this.options.projectCode, Number(this.runId))];
|
|
193
|
-
case 2:
|
|
194
|
-
_a.sent();
|
|
195
|
-
this.log(chalk_1.default(templateObject_9 || (templateObject_9 = __makeTemplateObject(["{green Run ", " completed}"], ["{green Run ", " completed}"])), this.runId));
|
|
196
|
-
return [3 /*break*/, 4];
|
|
197
|
-
case 3:
|
|
198
|
-
err_1 = _a.sent();
|
|
199
|
-
this.log("Error on completing run " + err_1);
|
|
200
|
-
return [3 /*break*/, 4];
|
|
201
|
-
case 4: return [2 /*return*/];
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
207
|
-
QaseReporter.prototype.getLastError = function () { };
|
|
208
|
-
QaseReporter.prototype.log = function (message) {
|
|
209
|
-
var optionalParams = [];
|
|
210
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
211
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
212
|
-
}
|
|
213
|
-
if (this.options.logging) {
|
|
214
|
-
// eslint-disable-next-line no-console
|
|
215
|
-
console.log.apply(console, __spreadArrays([chalk_1.default(templateObject_10 || (templateObject_10 = __makeTemplateObject(["{bold {blue qase:}} ", ""], ["{bold {blue qase:}} ", ""])), message)], optionalParams));
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
QaseReporter.prototype.getEnv = function (name) {
|
|
219
|
-
return process.env[name];
|
|
220
|
-
};
|
|
221
|
-
QaseReporter.prototype.getCaseIds = function (test) {
|
|
222
|
-
var regexp = /(\(Qase ID: ([\d,]+)\))/;
|
|
223
|
-
var results = regexp.exec(test.title);
|
|
224
|
-
if (results && results.length === 3) {
|
|
225
|
-
return results[2].split(',').map(function (value) { return Number.parseInt(value, 10); });
|
|
226
|
-
}
|
|
227
|
-
return [];
|
|
228
|
-
};
|
|
229
|
-
QaseReporter.prototype.logTestItem = function (test) {
|
|
230
|
-
var map = {
|
|
231
|
-
failed: chalk_1.default(templateObject_11 || (templateObject_11 = __makeTemplateObject(["{red Test ", " ", "}"], ["{red Test ", " ", "}"])), test.title, test.status),
|
|
232
|
-
passed: chalk_1.default(templateObject_12 || (templateObject_12 = __makeTemplateObject(["{green Test ", " ", "}"], ["{green Test ", " ", "}"])), test.title, test.status),
|
|
233
|
-
skipped: chalk_1.default(templateObject_13 || (templateObject_13 = __makeTemplateObject(["{blueBright Test ", " ", "}"], ["{blueBright Test ", " ", "}"])), test.title, test.status),
|
|
234
|
-
pending: chalk_1.default(templateObject_14 || (templateObject_14 = __makeTemplateObject(["{blueBright Test ", " ", "}"], ["{blueBright Test ", " ", "}"])), test.title, test.status),
|
|
235
|
-
disabled: chalk_1.default(templateObject_15 || (templateObject_15 = __makeTemplateObject(["{gray Test ", " ", "}"], ["{gray Test ", " ", "}"])), test.title, test.status),
|
|
236
|
-
};
|
|
237
|
-
if (test.status) {
|
|
238
|
-
this.log(map[test.status]);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
QaseReporter.prototype.createPreparedForPublishTestsArray = function (testResults) {
|
|
242
|
-
var _this = this;
|
|
243
|
-
var transformedMap = testResults.map(function (result) {
|
|
244
|
-
_this.logTestItem(result);
|
|
245
|
-
var fullPathToCase = result.ancestorTitles.join('\t');
|
|
246
|
-
var item = {
|
|
247
|
-
path: _this.options.rootSuiteTitle
|
|
248
|
-
? _this.options.rootSuiteTitle + "\t" + fullPathToCase
|
|
249
|
-
: fullPathToCase,
|
|
250
|
-
result: result.status,
|
|
251
|
-
duration: result.duration,
|
|
252
|
-
status: result.status,
|
|
253
|
-
title: result.title,
|
|
254
|
-
failureMessages: result.failureMessages,
|
|
255
|
-
};
|
|
256
|
-
var caseIds = _this.getCaseIds(result);
|
|
257
|
-
if (caseIds) {
|
|
258
|
-
item.caseIds = caseIds;
|
|
259
|
-
}
|
|
260
|
-
return item;
|
|
261
|
-
});
|
|
262
|
-
return transformedMap;
|
|
263
|
-
};
|
|
264
|
-
QaseReporter.prototype.publishBulkTestResult = function () {
|
|
265
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
266
|
-
var body, res, error_1;
|
|
267
|
-
return __generator(this, function (_a) {
|
|
268
|
-
switch (_a.label) {
|
|
269
|
-
case 0:
|
|
270
|
-
_a.trys.push([0, 2, , 3]);
|
|
271
|
-
body = {
|
|
272
|
-
results: this.createResultCasesArray(),
|
|
273
|
-
};
|
|
274
|
-
return [4 /*yield*/, this.api.results.createResultBulk(this.options.projectCode, Number(this.runId), body)];
|
|
275
|
-
case 1:
|
|
276
|
-
res = _a.sent();
|
|
277
|
-
if (res.status === 200) {
|
|
278
|
-
this.publishedResultsCount++;
|
|
279
|
-
}
|
|
280
|
-
return [3 /*break*/, 3];
|
|
281
|
-
case 2:
|
|
282
|
-
error_1 = _a.sent();
|
|
283
|
-
this.log(JSON.stringify(error_1));
|
|
284
|
-
return [3 /*break*/, 3];
|
|
285
|
-
case 3: return [2 /*return*/];
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
QaseReporter.prototype.checkProject = function (projectCode, cb) {
|
|
291
|
-
var _a;
|
|
292
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
293
|
-
var resp, err_2;
|
|
294
|
-
return __generator(this, function (_b) {
|
|
295
|
-
switch (_b.label) {
|
|
296
|
-
case 0:
|
|
297
|
-
_b.trys.push([0, 3, , 4]);
|
|
298
|
-
return [4 /*yield*/, this.api.projects.getProject(projectCode)];
|
|
299
|
-
case 1:
|
|
300
|
-
resp = _b.sent();
|
|
301
|
-
return [4 /*yield*/, cb(Boolean((_a = resp.data.result) === null || _a === void 0 ? void 0 : _a.code))];
|
|
302
|
-
case 2:
|
|
303
|
-
_b.sent();
|
|
304
|
-
return [3 /*break*/, 4];
|
|
305
|
-
case 3:
|
|
306
|
-
err_2 = _b.sent();
|
|
307
|
-
this.log(err_2);
|
|
308
|
-
this.isDisabled = true;
|
|
309
|
-
return [3 /*break*/, 4];
|
|
310
|
-
case 4: return [2 /*return*/];
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
};
|
|
315
|
-
QaseReporter.prototype.createRunObject = function (name, cases, args) {
|
|
316
|
-
return __assign({ title: name, cases: cases }, args);
|
|
317
|
-
};
|
|
318
|
-
QaseReporter.prototype.createRun = function (name, description, cb) {
|
|
319
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
320
|
-
var environmentId, runObject, res, err_3;
|
|
321
|
-
return __generator(this, function (_a) {
|
|
322
|
-
switch (_a.label) {
|
|
323
|
-
case 0:
|
|
324
|
-
_a.trys.push([0, 2, , 3]);
|
|
325
|
-
environmentId = Number.parseInt(this.getEnv(Envs.environmentId), 10) || this.options.environmentId;
|
|
326
|
-
runObject = this.createRunObject(name || "Automated run " + new Date().toISOString(), [], {
|
|
327
|
-
description: description || 'Jest automated run',
|
|
328
|
-
environment_id: environmentId,
|
|
329
|
-
is_autotest: true,
|
|
330
|
-
});
|
|
331
|
-
return [4 /*yield*/, this.api.runs.createRun(this.options.projectCode, runObject)];
|
|
332
|
-
case 1:
|
|
333
|
-
res = _a.sent();
|
|
334
|
-
cb(res.data);
|
|
335
|
-
return [3 /*break*/, 3];
|
|
336
|
-
case 2:
|
|
337
|
-
err_3 = _a.sent();
|
|
338
|
-
this.log("Error on creating run " + err_3);
|
|
339
|
-
this.isDisabled = true;
|
|
340
|
-
return [3 /*break*/, 3];
|
|
341
|
-
case 3: return [2 /*return*/];
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
};
|
|
346
|
-
QaseReporter.prototype.checkRun = function (runId, cb) {
|
|
347
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
348
|
-
var _this = this;
|
|
349
|
-
return __generator(this, function (_a) {
|
|
350
|
-
if (runId === undefined) {
|
|
351
|
-
cb(false);
|
|
352
|
-
return [2 /*return*/];
|
|
353
|
-
}
|
|
354
|
-
return [2 /*return*/, this.api.runs.getRun(this.options.projectCode, Number(runId))
|
|
355
|
-
.then(function (resp) {
|
|
356
|
-
var _a, _b;
|
|
357
|
-
_this.log("Get run result on checking run " + ((_a = resp.data.result) === null || _a === void 0 ? void 0 : _a.id));
|
|
358
|
-
cb(Boolean((_b = resp.data.result) === null || _b === void 0 ? void 0 : _b.id));
|
|
359
|
-
})
|
|
360
|
-
.catch(function (err) {
|
|
361
|
-
_this.log("Error on checking run " + err);
|
|
362
|
-
_this.isDisabled = true;
|
|
363
|
-
})];
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
};
|
|
367
|
-
QaseReporter.prototype.createResultCasesArray = function () {
|
|
368
|
-
return this.preparedTestCases.map(function (elem) {
|
|
369
|
-
var _a;
|
|
370
|
-
var failureMessages = elem.failureMessages.map(function (value) {
|
|
371
|
-
return value.replace(/\u001b\[.*?m/g, '');
|
|
372
|
-
});
|
|
373
|
-
var caseObject = {
|
|
374
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
375
|
-
status: Statuses[elem.status] || Statuses.failed,
|
|
376
|
-
time_ms: Number(elem.duration),
|
|
377
|
-
stacktrace: failureMessages.join('\n'),
|
|
378
|
-
comment: failureMessages.length > 0 ? failureMessages.map(function (value) { return value.split('\n')[0]; }).join('\n') : undefined,
|
|
379
|
-
defect: Statuses[elem.status] === Statuses.failed,
|
|
380
|
-
};
|
|
381
|
-
// Verifies that the user defined the ID through the use of the 'qase' wrapper;
|
|
382
|
-
if (elem.caseIds && ((_a = elem.caseIds) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
383
|
-
caseObject.case_id = elem.caseIds[0];
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
caseObject.case = {
|
|
387
|
-
title: elem.title,
|
|
388
|
-
suite_title: elem.path,
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
return caseObject;
|
|
392
|
-
});
|
|
393
|
-
};
|
|
394
|
-
QaseReporter.prototype.createHeaders = function () {
|
|
395
|
-
var nodeVersion = process.version, os = process.platform, arch = process.arch;
|
|
396
|
-
var npmVersion = child_process_1.execSync('npm -v', { encoding: 'utf8' }).replace(/['"\n]+/g, '');
|
|
397
|
-
var qaseapiVersion = this.getPackageVersion('qaseio');
|
|
398
|
-
var jestVersion = this.getPackageVersion('jest');
|
|
399
|
-
var jestCaseReporterVersion = this.getPackageVersion('jest-qase-reporter');
|
|
400
|
-
var xPlatformHeader = "node=" + nodeVersion + "; npm=" + npmVersion + "; os=" + os + "; arch=" + arch;
|
|
401
|
-
// eslint-disable-next-line max-len
|
|
402
|
-
var xClientHeader = "jest=" + jestVersion + "; qase-jest=" + jestCaseReporterVersion + "; qaseapi=" + qaseapiVersion;
|
|
403
|
-
return {
|
|
404
|
-
'X-Client': xClientHeader,
|
|
405
|
-
'X-Platform': xPlatformHeader,
|
|
406
|
-
};
|
|
407
|
-
};
|
|
408
|
-
QaseReporter.prototype.getPackageVersion = function (name) {
|
|
409
|
-
var UNDEFINED = 'undefined';
|
|
410
|
-
try {
|
|
411
|
-
var pathToPackageJson = require.resolve(name + "/package.json", { paths: [process.cwd()] });
|
|
412
|
-
if (pathToPackageJson) {
|
|
413
|
-
try {
|
|
414
|
-
var packageString = fs_1.readFileSync(pathToPackageJson, { encoding: 'utf8' });
|
|
415
|
-
if (packageString) {
|
|
416
|
-
var packageObject = JSON.parse(packageString);
|
|
417
|
-
return packageObject.version;
|
|
418
|
-
}
|
|
419
|
-
return UNDEFINED;
|
|
420
|
-
}
|
|
421
|
-
catch (error) {
|
|
422
|
-
return UNDEFINED;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
catch (error) {
|
|
427
|
-
return UNDEFINED;
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
return QaseReporter;
|
|
431
|
-
}());
|
|
432
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15;
|
|
433
|
-
module.exports = QaseReporter;
|
|
434
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
const reporter_1 = require("./reporter");
|
|
3
|
+
module.exports = reporter_1.JestQaseReporter;
|
package/dist/jest.d.ts
CHANGED
package/dist/jest.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
caseIds = caseId;
|
|
10
|
-
}
|
|
11
|
-
var newName = name + " (Qase ID: " + caseIds.join(',') + ")";
|
|
12
|
-
return newName;
|
|
13
|
-
},
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.qase = void 0;
|
|
4
|
+
const qase = (caseId, name) => {
|
|
5
|
+
const caseIds = Array.isArray(caseId) ? caseId : [caseId];
|
|
6
|
+
return `${name} (Qase ID: ${caseIds.join(',')})`;
|
|
14
7
|
};
|
|
15
|
-
|
|
8
|
+
exports.qase = qase;
|