cypress-qase-reporter 1.4.1 → 1.4.2-alpha.3
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 +34 -18
- package/dist/index.d.ts +11 -4
- package/dist/index.js +309 -122
- package/dist/index.js.map +1 -1
- package/dist/mocha.js +3 -0
- package/dist/mocha.js.map +1 -1
- package/dist/reportBulk.js +174 -0
- package/examples_cypress_v10/cypress/e2e/second.cy.js +59 -0
- package/examples_cypress_v10/cypress/fixtures/example.json +5 -0
- package/examples_cypress_v10/cypress/plugins/index.js +21 -0
- package/examples_cypress_v10/cypress/support/commands.js +25 -0
- package/examples_cypress_v10/cypress/support/e2e.js +20 -0
- package/examples_cypress_v10/cypress.config.js +30 -0
- package/examples_cypress_v10/package-lock.json +5198 -0
- package/examples_cypress_v10/package.json +17 -0
- package/examples_cypress_v10/screenshots/screenshot.png +0 -0
- package/examples_cypress_v6/cypress/fixtures/example.json +5 -0
- package/examples_cypress_v6/cypress/integration/sample_spec.js +39 -0
- package/examples_cypress_v6/cypress/plugins/index.js +21 -0
- package/examples_cypress_v6/cypress/support/commands.js +25 -0
- package/examples_cypress_v6/cypress/support/index.js +20 -0
- package/examples_cypress_v6/cypress.json +20 -0
- package/examples_cypress_v6/package-lock.json +6283 -0
- package/examples_cypress_v6/package.json +17 -0
- package/package.json +4 -3
- package/test/plugin.test.ts +170 -2
- package/docs/stdout.png +0 -0
package/README.md
CHANGED
|
@@ -38,16 +38,30 @@ describe('My First Test', () => {
|
|
|
38
38
|
);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
```
|
|
42
|
+
If you are going to use several specifications for execution and you have in config
|
|
43
|
+
```bash
|
|
44
|
+
"runComplete": true
|
|
45
|
+
```
|
|
46
|
+
then it is necessary to additionally set in the project settings
|
|
47
|
+
```
|
|
48
|
+
Allow to add results for cases in closed runs.
|
|
41
49
|
```
|
|
42
50
|
|
|
43
|
-
To run tests and create a test run, execute the command:
|
|
51
|
+
To run tests and create a test run, execute the command (for example from folder examples):
|
|
44
52
|
```bash
|
|
45
53
|
QASE_REPORT=1 npx cypress run
|
|
46
54
|
```
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
or
|
|
56
|
+
```bash
|
|
57
|
+
npm test
|
|
58
|
+
```
|
|
59
|
+
<p align="center">
|
|
60
|
+
<img width="65%" src="examples_cypress_v10/screenshots/screenshot.png">
|
|
61
|
+
</p>
|
|
49
62
|
|
|
50
63
|
A test run will be performed and available at:
|
|
64
|
+
|
|
51
65
|
```
|
|
52
66
|
https://app.qase.io/run/QASE_PROJECT_CODE
|
|
53
67
|
```
|
|
@@ -63,22 +77,13 @@ Reporter options (* - required):
|
|
|
63
77
|
`DEMOTR` is project code here)
|
|
64
78
|
- `runId` - Run ID from Qase TMS (also can be got from run URL)
|
|
65
79
|
- `logging` [true/false] - Enabled debug logging from reporter or not
|
|
80
|
+
- `environmentId` - To execute with the sending of the envinroment information
|
|
81
|
+
- `basePath` - URL Qase.io
|
|
82
|
+
- `screenshotFolder` - Folder for save screenshot cypress,
|
|
83
|
+
- `sendScreenshot` [true/false] - Permission to send screenshots to Qase TMS
|
|
84
|
+
- `runComplete` [true/false] - Permission for automatic completion of the test run
|
|
66
85
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
```json
|
|
70
|
-
{
|
|
71
|
-
"reporter": "cypress-qase-reporter",
|
|
72
|
-
"reporterOptions": {
|
|
73
|
-
"apiToken": "api_key",
|
|
74
|
-
"projectCode": "project_code",
|
|
75
|
-
"runId": 45,
|
|
76
|
-
"logging": true
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
You can check example configuration with multiple reporters in [demo project](./demo/cypress.json).
|
|
86
|
+
#### You can check example configuration with multiple reporters in [demo project (cypress v10)](examples_cypress_v10/cypress.config.js) and [demo project (cypress v6)](examples_cypress_v6/cypress.json).
|
|
82
87
|
|
|
83
88
|
Supported ENV variables:
|
|
84
89
|
|
|
@@ -87,6 +92,17 @@ Supported ENV variables:
|
|
|
87
92
|
- `QASE_RUN_ID` - Pass Run ID from ENV and override reporter options
|
|
88
93
|
- `QASE_RUN_NAME` - Set custom Run name, when new run is created
|
|
89
94
|
- `QASE_RUN_DESCRIPTION` - Set custom Run description, when new run is created
|
|
95
|
+
- `QASE_API_TOKEN` - Token for API access, you can find more information
|
|
96
|
+
[here](https://developers.qase.io/#authentication)
|
|
97
|
+
- `QASE_API_BASE_URL` - URL Qase.io, default value `https://api.qase.io/v1`
|
|
98
|
+
- `QASE_ENVIRONMENT_ID` - To execute with the sending of the envinroment information
|
|
99
|
+
- `QASE_SCREENSHOT_FOLDER` - Folder for save screenshot cypress
|
|
100
|
+
- `QASE_SCREENSHOT_SENDING` - Permission to send screenshots to Qase TMS
|
|
101
|
+
- `QASE_RUN_COMPLETE` - Permission for automatic completion of the test run
|
|
102
|
+
|
|
103
|
+
## Requirements
|
|
104
|
+
|
|
105
|
+
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/)
|
|
90
106
|
|
|
91
107
|
<!-- references -->
|
|
92
108
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { MochaOptions, Runner, reporters } from 'mocha';
|
|
2
2
|
declare class CypressQaseReporter extends reporters.Base {
|
|
3
|
+
testCasesForPublishingCount: number;
|
|
3
4
|
private api;
|
|
4
5
|
private pending;
|
|
5
|
-
private results;
|
|
6
6
|
private shouldPublish;
|
|
7
|
+
private results;
|
|
7
8
|
private options;
|
|
8
9
|
private runId?;
|
|
10
|
+
private isDisabled;
|
|
11
|
+
private resultsForPublishing;
|
|
9
12
|
constructor(runner: Runner, options: MochaOptions);
|
|
13
|
+
private static getEnv;
|
|
14
|
+
private static getCaseId;
|
|
15
|
+
private static createRunObject;
|
|
16
|
+
private static createHeaders;
|
|
17
|
+
private static getSuitePath;
|
|
18
|
+
private static getPackageVersion;
|
|
10
19
|
private log;
|
|
11
20
|
private addRunnerListeners;
|
|
12
21
|
private checkProject;
|
|
13
22
|
private createRun;
|
|
14
23
|
private checkRun;
|
|
15
|
-
private getEnv;
|
|
16
24
|
private saveRunId;
|
|
17
|
-
private getCaseId;
|
|
18
25
|
private logTestItem;
|
|
19
|
-
private
|
|
26
|
+
private transformCaseResultToBulkObject;
|
|
20
27
|
}
|
|
21
28
|
export = CypressQaseReporter;
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,53 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
16
16
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
17
17
|
return cooked;
|
|
18
18
|
};
|
|
19
|
+
var __assign = (this && this.__assign) || function () {
|
|
20
|
+
__assign = Object.assign || function(t) {
|
|
21
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
22
|
+
s = arguments[i];
|
|
23
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24
|
+
t[p] = s[p];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
};
|
|
28
|
+
return __assign.apply(this, arguments);
|
|
29
|
+
};
|
|
30
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
31
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
32
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
34
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
35
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
36
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
40
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
41
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
42
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
43
|
+
function step(op) {
|
|
44
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
45
|
+
while (_) try {
|
|
46
|
+
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;
|
|
47
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
48
|
+
switch (op[0]) {
|
|
49
|
+
case 0: case 1: t = op; break;
|
|
50
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
51
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
52
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
53
|
+
default:
|
|
54
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
55
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
56
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
57
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
58
|
+
if (t[2]) _.ops.pop();
|
|
59
|
+
_.trys.pop(); continue;
|
|
60
|
+
}
|
|
61
|
+
op = body.call(thisArg, _);
|
|
62
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
63
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
64
|
+
}
|
|
65
|
+
};
|
|
19
66
|
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
20
67
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
21
68
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
@@ -27,68 +74,166 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
74
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
75
|
};
|
|
29
76
|
/* eslint-disable no-console */
|
|
77
|
+
/* eslint-disable camelcase */
|
|
78
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
79
|
+
var src_1 = require("qaseio/dist/src");
|
|
30
80
|
var mocha_1 = require("mocha");
|
|
31
|
-
var
|
|
81
|
+
var child_process_1 = require("child_process");
|
|
32
82
|
var qaseio_1 = require("qaseio");
|
|
33
83
|
var chalk_1 = __importDefault(require("chalk"));
|
|
84
|
+
var fs_1 = require("fs");
|
|
34
85
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
35
86
|
var _a = mocha_1.Runner.constants, EVENT_TEST_FAIL = _a.EVENT_TEST_FAIL, EVENT_TEST_PASS = _a.EVENT_TEST_PASS, EVENT_TEST_PENDING = _a.EVENT_TEST_PENDING, EVENT_RUN_END = _a.EVENT_RUN_END;
|
|
36
87
|
var Envs;
|
|
37
88
|
(function (Envs) {
|
|
38
89
|
Envs["report"] = "QASE_REPORT";
|
|
39
90
|
Envs["apiToken"] = "QASE_API_TOKEN";
|
|
91
|
+
Envs["basePath"] = "QASE_API_BASE_URL";
|
|
92
|
+
Envs["projectCode"] = "QASE_PROJECT_CODE";
|
|
40
93
|
Envs["runId"] = "QASE_RUN_ID";
|
|
41
94
|
Envs["runName"] = "QASE_RUN_NAME";
|
|
42
95
|
Envs["runDescription"] = "QASE_RUN_DESCRIPTION";
|
|
96
|
+
Envs["environmentId"] = "QASE_ENVIRONMENT_ID";
|
|
97
|
+
Envs["screenshotFolder"] = "QASE_SCREENSHOT_FOLDER";
|
|
98
|
+
Envs["sendScreenshot"] = "QASE_SCREENSHOT_SENDING";
|
|
99
|
+
Envs["runComplete"] = "QASE_RUN_COMPLETE";
|
|
100
|
+
Envs["rootSuiteTitle"] = "QASE_ROOT_SUITE_TITLE";
|
|
43
101
|
})(Envs || (Envs = {}));
|
|
44
102
|
var CypressQaseReporter = /** @class */ (function (_super) {
|
|
45
103
|
__extends(CypressQaseReporter, _super);
|
|
46
104
|
function CypressQaseReporter(runner, options) {
|
|
47
105
|
var _this = _super.call(this, runner, options) || this;
|
|
106
|
+
_this.testCasesForPublishingCount = 0;
|
|
48
107
|
_this.pending = [];
|
|
108
|
+
_this.shouldPublish = [];
|
|
49
109
|
_this.results = [];
|
|
50
|
-
_this.
|
|
110
|
+
_this.isDisabled = false;
|
|
111
|
+
_this.resultsForPublishing = [];
|
|
51
112
|
_this.options = options.reporterOptions;
|
|
52
|
-
_this.
|
|
53
|
-
|
|
113
|
+
_this.options.rootSuiteTitle = CypressQaseReporter.getEnv(Envs.rootSuiteTitle) ||
|
|
114
|
+
options.reporterOptions.rootSuiteTitle
|
|
115
|
+
|| '';
|
|
116
|
+
_this.options.projectCode = options.reporterOptions.projectCode || CypressQaseReporter.getEnv(Envs.projectCode);
|
|
117
|
+
_this.api = new qaseio_1.QaseApi(_this.options.apiToken || CypressQaseReporter.getEnv(Envs.apiToken) || '', CypressQaseReporter.getEnv(Envs.basePath) || _this.options.basePath, CypressQaseReporter.createHeaders());
|
|
118
|
+
if (!CypressQaseReporter.getEnv(Envs.report)) {
|
|
54
119
|
return _this;
|
|
55
120
|
}
|
|
56
121
|
_this.log(chalk_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{yellow Current PID: ", "}"], ["{yellow Current PID: ", "}"])), process.pid));
|
|
57
122
|
_this.addRunnerListeners(runner);
|
|
58
|
-
_this.checkProject(_this.options.projectCode, function (prjExists) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
123
|
+
void _this.checkProject(_this.options.projectCode, function (prjExists) { return __awaiter(_this, void 0, void 0, function () {
|
|
124
|
+
var _this = this;
|
|
125
|
+
return __generator(this, function (_a) {
|
|
126
|
+
switch (_a.label) {
|
|
127
|
+
case 0:
|
|
128
|
+
if (!prjExists) return [3 /*break*/, 5];
|
|
129
|
+
this.log(chalk_1.default(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{green Project ", " exists}"], ["{green Project ", " exists}"])), this.options.projectCode));
|
|
130
|
+
if (!(CypressQaseReporter.getEnv(Envs.runId) || this.options.runId)) return [3 /*break*/, 2];
|
|
131
|
+
this.saveRunId(CypressQaseReporter.getEnv(Envs.runId) || this.options.runId);
|
|
132
|
+
return [4 /*yield*/, this.checkRun(this.runId, function (runExists) {
|
|
133
|
+
var run = _this.runId;
|
|
134
|
+
if (runExists) {
|
|
135
|
+
_this.log(chalk_1.default(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{green Using run ", " to publish test results}"], ["{green Using run ", " to publish test results}"])), run));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
_this.log(chalk_1.default(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{red Run ", " does not exist}"], ["{red Run ", " does not exist}"])), run));
|
|
139
|
+
}
|
|
140
|
+
})];
|
|
141
|
+
case 1:
|
|
142
|
+
_a.sent();
|
|
143
|
+
return [3 /*break*/, 4];
|
|
144
|
+
case 2:
|
|
145
|
+
if (!!this.runId) return [3 /*break*/, 4];
|
|
146
|
+
return [4 /*yield*/, this.createRun(CypressQaseReporter.getEnv(Envs.runName), CypressQaseReporter.getEnv(Envs.runDescription), function (created) {
|
|
147
|
+
var _a;
|
|
148
|
+
if (created) {
|
|
149
|
+
_this.runId = (_a = created.result) === null || _a === void 0 ? void 0 : _a.id;
|
|
150
|
+
process.env.QASE_RUN_ID = String(_this === null || _this === void 0 ? void 0 : _this.runId);
|
|
151
|
+
_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));
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
_this.log(chalk_1.default(templateObject_6 || (templateObject_6 = __makeTemplateObject(["{red Could not create run in project ", "}"], ["{red Could not create run in project ", "}"])), _this.options.projectCode));
|
|
155
|
+
_this.isDisabled = true;
|
|
156
|
+
}
|
|
157
|
+
})];
|
|
158
|
+
case 3:
|
|
159
|
+
_a.sent();
|
|
160
|
+
_a.label = 4;
|
|
161
|
+
case 4: return [3 /*break*/, 6];
|
|
162
|
+
case 5:
|
|
163
|
+
this.log(chalk_1.default(templateObject_7 || (templateObject_7 = __makeTemplateObject(["{red Project ", " does not exist}"], ["{red Project ", " does not exist}"])), this.options.projectCode));
|
|
164
|
+
_a.label = 6;
|
|
165
|
+
case 6: return [2 /*return*/];
|
|
84
166
|
}
|
|
167
|
+
});
|
|
168
|
+
}); });
|
|
169
|
+
return _this;
|
|
170
|
+
}
|
|
171
|
+
CypressQaseReporter.getEnv = function (name) {
|
|
172
|
+
return process.env[name];
|
|
173
|
+
};
|
|
174
|
+
CypressQaseReporter.getCaseId = function (test) {
|
|
175
|
+
var regexp = /(\(Qase ID: ([\d,]+)\))/;
|
|
176
|
+
var results = regexp.exec(test.title);
|
|
177
|
+
if (results && results.length === 3) {
|
|
178
|
+
return results[2].split(',').map(function (value) { return Number.parseInt(value, 10); });
|
|
179
|
+
}
|
|
180
|
+
return [];
|
|
181
|
+
};
|
|
182
|
+
CypressQaseReporter.createRunObject = function (name, cases, args) {
|
|
183
|
+
return __assign({ title: name, cases: cases }, args);
|
|
184
|
+
};
|
|
185
|
+
CypressQaseReporter.createHeaders = function () {
|
|
186
|
+
var nodeVersion = process.version, os = process.platform, arch = process.arch;
|
|
187
|
+
var npmVersion = child_process_1.execSync('npm -v', { encoding: 'utf8' }).replace(/['"\n]+/g, '');
|
|
188
|
+
var qaseapiVersion = CypressQaseReporter.getPackageVersion('qaseio');
|
|
189
|
+
var cypressVersion = CypressQaseReporter.getPackageVersion('cypress');
|
|
190
|
+
var cypressCaseReporterVersion = this.getPackageVersion('cypress-qase-reporter');
|
|
191
|
+
var xPlatformHeader = "node=" + nodeVersion + "; npm=" + npmVersion + "; os=" + os + "; arch=" + arch;
|
|
192
|
+
var xClientHeader = "cypress=" + cypressVersion + "; qase-cypress=" + cypressCaseReporterVersion + "; qaseapi=" + qaseapiVersion;
|
|
193
|
+
return {
|
|
194
|
+
'X-Client': xClientHeader,
|
|
195
|
+
'X-Platform': xPlatformHeader,
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
CypressQaseReporter.getSuitePath = function (suite) {
|
|
199
|
+
if (suite.parent) {
|
|
200
|
+
var parentSuite = String(CypressQaseReporter.getSuitePath(suite.parent));
|
|
201
|
+
if (parentSuite) {
|
|
202
|
+
return parentSuite + '\t' + String(suite === null || suite === void 0 ? void 0 : suite.title);
|
|
85
203
|
}
|
|
86
204
|
else {
|
|
87
|
-
|
|
205
|
+
return String(suite === null || suite === void 0 ? void 0 : suite.title);
|
|
88
206
|
}
|
|
89
|
-
}
|
|
90
|
-
return
|
|
91
|
-
|
|
207
|
+
}
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
209
|
+
return suite.title;
|
|
210
|
+
};
|
|
211
|
+
CypressQaseReporter.getPackageVersion = function (name) {
|
|
212
|
+
var UNDEFINED = 'undefined';
|
|
213
|
+
try {
|
|
214
|
+
var pathToPackageJson = require.resolve(name + "/package.json", {
|
|
215
|
+
paths: [process.cwd()],
|
|
216
|
+
});
|
|
217
|
+
if (pathToPackageJson) {
|
|
218
|
+
try {
|
|
219
|
+
var packageString = fs_1.readFileSync(pathToPackageJson, {
|
|
220
|
+
encoding: 'utf8',
|
|
221
|
+
});
|
|
222
|
+
if (packageString) {
|
|
223
|
+
var packageObject = JSON.parse(packageString);
|
|
224
|
+
return packageObject.version;
|
|
225
|
+
}
|
|
226
|
+
return UNDEFINED;
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
return UNDEFINED;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
return UNDEFINED;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
92
237
|
CypressQaseReporter.prototype.log = function (message) {
|
|
93
238
|
var optionalParams = [];
|
|
94
239
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -101,67 +246,124 @@ var CypressQaseReporter = /** @class */ (function (_super) {
|
|
|
101
246
|
CypressQaseReporter.prototype.addRunnerListeners = function (runner) {
|
|
102
247
|
var _this = this;
|
|
103
248
|
runner.on(EVENT_TEST_PASS, function (test) {
|
|
104
|
-
_this.
|
|
249
|
+
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.PASSED);
|
|
105
250
|
});
|
|
106
251
|
runner.on(EVENT_TEST_PENDING, function (test) {
|
|
107
|
-
_this.
|
|
252
|
+
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.SKIPPED);
|
|
108
253
|
});
|
|
109
254
|
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
110
|
-
_this.
|
|
255
|
+
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.FAILED);
|
|
111
256
|
});
|
|
112
|
-
runner.
|
|
113
|
-
if (_this.
|
|
114
|
-
_this.log('
|
|
257
|
+
runner.addListener(EVENT_RUN_END, function () {
|
|
258
|
+
if (_this.resultsForPublishing.length === 0) {
|
|
259
|
+
_this.log('Nothing to send.');
|
|
115
260
|
}
|
|
116
|
-
if (_this.runId
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
261
|
+
else if (_this.runId) {
|
|
262
|
+
var config = {
|
|
263
|
+
apiToken: CypressQaseReporter.getEnv(Envs.apiToken) || _this.options.apiToken || '',
|
|
264
|
+
basePath: CypressQaseReporter.getEnv(Envs.basePath) || _this.options.basePath,
|
|
265
|
+
headers: CypressQaseReporter.createHeaders(),
|
|
266
|
+
code: _this.options.projectCode,
|
|
267
|
+
runId: Number(_this.runId),
|
|
268
|
+
body: {
|
|
269
|
+
results: _this.resultsForPublishing,
|
|
270
|
+
},
|
|
271
|
+
runComplete: CypressQaseReporter.getEnv(Envs.runComplete) || _this.options.runComplete || false,
|
|
272
|
+
};
|
|
273
|
+
var screenshotsConfig = {
|
|
274
|
+
screenshotFolder: CypressQaseReporter.getEnv(Envs.screenshotFolder)
|
|
275
|
+
|| _this.options.screenshotFolder
|
|
276
|
+
|| 'screenshots',
|
|
277
|
+
sendScreenshot: CypressQaseReporter.getEnv(Envs.screenshotFolder)
|
|
278
|
+
|| _this.options.sendScreenshot
|
|
279
|
+
|| false,
|
|
280
|
+
};
|
|
281
|
+
child_process_1.spawnSync('node', [__dirname + "/reportBulk.js"], {
|
|
282
|
+
stdio: 'inherit',
|
|
283
|
+
env: Object.assign(process.env, {
|
|
284
|
+
reporting_config: JSON.stringify(config),
|
|
285
|
+
screenshots_config: JSON.stringify(screenshotsConfig),
|
|
286
|
+
}),
|
|
287
|
+
});
|
|
128
288
|
}
|
|
129
289
|
});
|
|
130
290
|
};
|
|
131
291
|
CypressQaseReporter.prototype.checkProject = function (projectCode, cb) {
|
|
132
|
-
var
|
|
133
|
-
this
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
292
|
+
var _a;
|
|
293
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
+
var resp, err_1;
|
|
295
|
+
return __generator(this, function (_b) {
|
|
296
|
+
switch (_b.label) {
|
|
297
|
+
case 0:
|
|
298
|
+
_b.trys.push([0, 3, , 4]);
|
|
299
|
+
return [4 /*yield*/, this.api.projects.getProject(projectCode)];
|
|
300
|
+
case 1:
|
|
301
|
+
resp = _b.sent();
|
|
302
|
+
return [4 /*yield*/, cb(Boolean((_a = resp.data.result) === null || _a === void 0 ? void 0 : _a.code))];
|
|
303
|
+
case 2:
|
|
304
|
+
_b.sent();
|
|
305
|
+
return [3 /*break*/, 4];
|
|
306
|
+
case 3:
|
|
307
|
+
err_1 = _b.sent();
|
|
308
|
+
this.log(err_1);
|
|
309
|
+
this.isDisabled = true;
|
|
310
|
+
return [3 /*break*/, 4];
|
|
311
|
+
case 4: return [2 /*return*/];
|
|
312
|
+
}
|
|
313
|
+
});
|
|
137
314
|
});
|
|
138
315
|
};
|
|
139
316
|
CypressQaseReporter.prototype.createRun = function (name, description, cb) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
317
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
318
|
+
var environmentId, runObject, res, err_2;
|
|
319
|
+
return __generator(this, function (_a) {
|
|
320
|
+
switch (_a.label) {
|
|
321
|
+
case 0:
|
|
322
|
+
_a.trys.push([0, 2, , 3]);
|
|
323
|
+
environmentId = Number(CypressQaseReporter.getEnv(Envs.environmentId)) ||
|
|
324
|
+
this.options.environmentId;
|
|
325
|
+
runObject = CypressQaseReporter.createRunObject(name || "Automated run " + new Date().toISOString(), [], {
|
|
326
|
+
description: description || 'Cypress automated run',
|
|
327
|
+
environment_id: environmentId,
|
|
328
|
+
is_autotest: true,
|
|
329
|
+
});
|
|
330
|
+
return [4 /*yield*/, this.api.runs.createRun(this.options.projectCode, runObject)];
|
|
331
|
+
case 1:
|
|
332
|
+
res = _a.sent();
|
|
333
|
+
cb(res.data);
|
|
334
|
+
return [3 /*break*/, 3];
|
|
335
|
+
case 2:
|
|
336
|
+
err_2 = _a.sent();
|
|
337
|
+
this.log("Error on creating run " + err_2);
|
|
338
|
+
this.isDisabled = true;
|
|
339
|
+
return [3 /*break*/, 3];
|
|
340
|
+
case 3: return [2 /*return*/];
|
|
341
|
+
}
|
|
342
|
+
});
|
|
148
343
|
});
|
|
149
344
|
};
|
|
345
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
150
346
|
CypressQaseReporter.prototype.checkRun = function (runId, cb) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
|
355
|
+
.getRun(this.options.projectCode, Number(runId))
|
|
356
|
+
.then(function (resp) {
|
|
357
|
+
var _a, _b;
|
|
358
|
+
_this.log("Get run result on checking run " + ((_a = resp.data.result) === null || _a === void 0 ? void 0 : _a.id));
|
|
359
|
+
cb(Boolean((_b = resp.data.result) === null || _b === void 0 ? void 0 : _b.id));
|
|
360
|
+
})
|
|
361
|
+
.catch(function (err) {
|
|
362
|
+
_this.log("Error on checking run " + err);
|
|
363
|
+
_this.isDisabled = true;
|
|
364
|
+
})];
|
|
157
365
|
});
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
cb(false);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
CypressQaseReporter.prototype.getEnv = function (name) {
|
|
164
|
-
return process.env[name];
|
|
366
|
+
});
|
|
165
367
|
};
|
|
166
368
|
CypressQaseReporter.prototype.saveRunId = function (runId) {
|
|
167
369
|
this.runId = runId;
|
|
@@ -175,62 +377,47 @@ var CypressQaseReporter = /** @class */ (function (_super) {
|
|
|
175
377
|
}
|
|
176
378
|
}
|
|
177
379
|
};
|
|
178
|
-
CypressQaseReporter.prototype.getCaseId = function (test) {
|
|
179
|
-
var regexp = /(\(Qase ID: ([\d,]+)\))/;
|
|
180
|
-
var results = regexp.exec(test.title);
|
|
181
|
-
if (results && results.length === 3) {
|
|
182
|
-
return results[2].split(',').map(function (value) { return Number.parseInt(value, 10); });
|
|
183
|
-
}
|
|
184
|
-
return [];
|
|
185
|
-
};
|
|
186
380
|
CypressQaseReporter.prototype.logTestItem = function (test) {
|
|
187
381
|
var map = {
|
|
188
|
-
failed: chalk_1.default(
|
|
189
|
-
passed: chalk_1.default(
|
|
190
|
-
pending: chalk_1.default(
|
|
382
|
+
failed: chalk_1.default(templateObject_9 || (templateObject_9 = __makeTemplateObject(["{red Test ", " ", "}"], ["{red Test ", " ", "}"])), test.title, test.state),
|
|
383
|
+
passed: chalk_1.default(templateObject_10 || (templateObject_10 = __makeTemplateObject(["{green Test ", " ", "}"], ["{green Test ", " ", "}"])), test.title, test.state),
|
|
384
|
+
pending: chalk_1.default(templateObject_11 || (templateObject_11 = __makeTemplateObject(["{blueBright Test ", " ", "}"], ["{blueBright Test ", " ", "}"])), test.title, test.state),
|
|
191
385
|
};
|
|
192
386
|
if (test.state) {
|
|
193
387
|
this.log(map[test.state]);
|
|
194
388
|
}
|
|
195
389
|
};
|
|
196
|
-
CypressQaseReporter.prototype.
|
|
390
|
+
CypressQaseReporter.prototype.transformCaseResultToBulkObject = function (test, status) {
|
|
197
391
|
var _this = this;
|
|
392
|
+
var _a;
|
|
198
393
|
this.logTestItem(test);
|
|
199
|
-
var caseIds =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
.then(function (res) {
|
|
214
|
-
_this.results.push({ test: test, result: res.data });
|
|
215
|
-
_this.log(chalk_1.default(templateObject_16 || (templateObject_16 = __makeTemplateObject(["{gray Result published: ", " ", "}", ""], ["{gray Result published: ", " ", "}", ""])), test.title, res.data.hash, add_1));
|
|
216
|
-
_this.shouldPublish--;
|
|
217
|
-
})
|
|
218
|
-
.catch(function (err) {
|
|
219
|
-
_this.log(err);
|
|
220
|
-
_this.shouldPublish--;
|
|
221
|
-
});
|
|
222
|
-
}
|
|
394
|
+
var caseIds = CypressQaseReporter.getCaseId(test);
|
|
395
|
+
var caseObject = {
|
|
396
|
+
status: status,
|
|
397
|
+
time_ms: test.duration || 0,
|
|
398
|
+
stacktrace: (_a = test.err) === null || _a === void 0 ? void 0 : _a.stack,
|
|
399
|
+
comment: test.err ? test.err.name + ": " + test.err.message : '',
|
|
400
|
+
defect: status === src_1.ResultCreateStatusEnum.FAILED,
|
|
401
|
+
};
|
|
402
|
+
if (caseIds.length === 0) {
|
|
403
|
+
caseObject.case = {
|
|
404
|
+
title: test.title,
|
|
405
|
+
suite_title: this.options.rootSuiteTitle
|
|
406
|
+
? this.options.rootSuiteTitle + "\t" + CypressQaseReporter.getSuitePath(test.parent)
|
|
407
|
+
: CypressQaseReporter.getSuitePath(test.parent),
|
|
223
408
|
};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
409
|
+
this.resultsForPublishing.push(caseObject);
|
|
410
|
+
this.log(chalk_1.default(templateObject_12 || (templateObject_12 = __makeTemplateObject(["{gray Result prepared for publish: ", " }"], ["{gray Result prepared for publish: ", " }"])), test.title));
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
caseIds.forEach(function (caseId) {
|
|
414
|
+
var caseObjectWithId = __assign({ case_id: caseId }, caseObject);
|
|
415
|
+
_this.resultsForPublishing.push(caseObjectWithId);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
231
418
|
};
|
|
232
419
|
return CypressQaseReporter;
|
|
233
420
|
}(mocha_1.reporters.Base));
|
|
234
|
-
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
|
|
421
|
+
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;
|
|
235
422
|
module.exports = CypressQaseReporter;
|
|
236
423
|
//# sourceMappingURL=index.js.map
|