cypress-qase-reporter 1.4.3 → 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 +32 -28
- package/dist/configSchema.d.ts +4 -0
- package/dist/configSchema.js +25 -0
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +5 -0
- package/dist/index.d.ts +1 -27
- package/dist/index.js +2 -422
- package/dist/mocha.d.ts +2 -4
- package/dist/mocha.js +7 -18
- package/dist/options.d.ts +3 -0
- package/dist/options.js +2 -0
- package/dist/reporter.d.ts +65 -0
- package/dist/reporter.js +130 -0
- package/dist/utils/traverse-dir.d.ts +1 -0
- package/dist/utils/traverse-dir.js +25 -0
- package/package.json +44 -41
- package/tsconfig.build.json +9 -0
- package/dist/index.js.map +0 -1
- package/dist/mocha.js.map +0 -1
- package/dist/reportBulk.js +0 -174
- package/examples_cypress_v10/cypress/e2e/second.cy.js +0 -59
- package/examples_cypress_v10/cypress/fixtures/example.json +0 -5
- package/examples_cypress_v10/cypress/plugins/index.js +0 -21
- package/examples_cypress_v10/cypress/support/commands.js +0 -25
- package/examples_cypress_v10/cypress/support/e2e.js +0 -20
- package/examples_cypress_v10/cypress.config.js +0 -30
- package/examples_cypress_v10/package-lock.json +0 -5198
- package/examples_cypress_v10/package.json +0 -17
- package/examples_cypress_v6/cypress/fixtures/example.json +0 -5
- package/examples_cypress_v6/cypress/integration/sample_spec.js +0 -39
- package/examples_cypress_v6/cypress/plugins/index.js +0 -21
- package/examples_cypress_v6/cypress/support/commands.js +0 -25
- package/examples_cypress_v6/cypress/support/index.js +0 -20
- package/examples_cypress_v6/cypress.json +0 -20
- package/examples_cypress_v6/package-lock.json +0 -6283
- package/examples_cypress_v6/package.json +0 -17
- package/test/plugin.test.ts +0 -179
- /package/{examples_cypress_v10/screenshots → screenshots}/screenshot.png +0 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install cypress-qase-reporter
|
|
|
13
13
|
If you want to decorate come test with Qase Case ID you could use qase function:
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import { qase } from 'cypress-qase-reporter
|
|
16
|
+
import { qase } from 'cypress-qase-reporter';
|
|
17
17
|
|
|
18
18
|
describe('My First Test', () => {
|
|
19
19
|
qase([1,2],
|
|
@@ -40,8 +40,12 @@ describe('My First Test', () => {
|
|
|
40
40
|
|
|
41
41
|
```
|
|
42
42
|
If you are going to use several specifications for execution and you have in config
|
|
43
|
-
```
|
|
44
|
-
"
|
|
43
|
+
```json
|
|
44
|
+
"testops": {
|
|
45
|
+
"run": {
|
|
46
|
+
"complete": true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
45
49
|
```
|
|
46
50
|
then it is necessary to additionally set in the project settings
|
|
47
51
|
```
|
|
@@ -50,14 +54,14 @@ Allow to add results for cases in closed runs.
|
|
|
50
54
|
|
|
51
55
|
To run tests and create a test run, execute the command (for example from folder examples):
|
|
52
56
|
```bash
|
|
53
|
-
|
|
57
|
+
QASE_MODE=testops npx cypress run
|
|
54
58
|
```
|
|
55
59
|
or
|
|
56
60
|
```bash
|
|
57
61
|
npm test
|
|
58
62
|
```
|
|
59
63
|
<p align="center">
|
|
60
|
-
<img width="65%" src="
|
|
64
|
+
<img width="65%" src="./screenshots/screenshot.png">
|
|
61
65
|
</p>
|
|
62
66
|
|
|
63
67
|
A test run will be performed and available at:
|
|
@@ -70,40 +74,40 @@ https://app.qase.io/run/QASE_PROJECT_CODE
|
|
|
70
74
|
|
|
71
75
|
Reporter options (* - required):
|
|
72
76
|
|
|
73
|
-
-
|
|
77
|
+
- `mode` - `testops`/`off` Enables reporter, default - `off`
|
|
78
|
+
- `debug` - Enables debug logging, defaule - `false`
|
|
79
|
+
- `environment` - To execute with the sending of the envinroment information
|
|
80
|
+
- *`testops.api.token` - Token for API access, you can find more information
|
|
74
81
|
[here](https://developers.qase.io/#authentication)
|
|
75
|
-
- *`
|
|
76
|
-
page of your project: `https://app.qase.io/project/DEMOTR` -
|
|
82
|
+
- *`testops.project` - Code of your project (can be extracted from main
|
|
83
|
+
page of your project: `https://app.qase.io/project/DEMOTR` -
|
|
77
84
|
`DEMOTR` is project code here)
|
|
78
|
-
- `
|
|
79
|
-
- `
|
|
80
|
-
- `
|
|
81
|
-
- `
|
|
82
|
-
- `
|
|
83
|
-
- `
|
|
84
|
-
- `runComplete` [true/false] - Permission for automatic completion of the test run
|
|
85
|
+
- `testops.uploadAttachments` - Permission to send screenshots to Qase TMS
|
|
86
|
+
- `testops.run.id` - Pass Run ID
|
|
87
|
+
- `testops.run.title` - Set custom Run name, when new run is created
|
|
88
|
+
- `testops.run.description` - Set custom Run description, when new run is created
|
|
89
|
+
- `testops.run.complete` - Whether the run should be completed
|
|
90
|
+
- `framework.cypress.screenshotFolder` - Folder for save screenshot cypress
|
|
85
91
|
|
|
86
|
-
#### You can check example configuration with multiple reporters in [demo project
|
|
92
|
+
#### You can check example configuration with multiple reporters in [demo project](../examples/cypress/cypress.config.js).
|
|
87
93
|
|
|
88
94
|
Supported ENV variables:
|
|
89
95
|
|
|
90
|
-
- `
|
|
91
|
-
|
|
92
|
-
- `
|
|
93
|
-
- `
|
|
94
|
-
- `
|
|
95
|
-
- `
|
|
96
|
-
|
|
97
|
-
- `
|
|
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
|
|
96
|
+
- `QASE_MODE` - Same as `mode`
|
|
97
|
+
- `QASE_DEBUG` - Same as `debug`
|
|
98
|
+
- `QASE_ENVIRONMENT` - Same as `environment`
|
|
99
|
+
- `QASE_TESTOPS_API_TOKEN` - Same as `testops.api.token`
|
|
100
|
+
- `QASE_TESTOPS_PROJECT` - Same as `testops.project`
|
|
101
|
+
- `QASE_TESTOPS_RUN_ID` - Pass Run ID from ENV and override reporter option `testops.run.id`
|
|
102
|
+
- `QASE_TESTOPS_RUN_TITLE` - Same as `testops.run.title`
|
|
103
|
+
- `QASE_TESTOPS_RUN_DESCRIPTION` - Same as `testops.run.description`
|
|
102
104
|
|
|
103
105
|
## Requirements
|
|
104
106
|
|
|
105
107
|
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/)
|
|
106
108
|
|
|
109
|
+
`cypress >= 8.0.0`
|
|
110
|
+
|
|
107
111
|
<!-- references -->
|
|
108
112
|
|
|
109
113
|
[auth]: https://developers.qase.io/#authentication
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configSchema = void 0;
|
|
4
|
+
exports.configSchema = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
nullable: true,
|
|
7
|
+
properties: {
|
|
8
|
+
framework: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
nullable: true,
|
|
11
|
+
properties: {
|
|
12
|
+
cypress: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
nullable: true,
|
|
15
|
+
properties: {
|
|
16
|
+
screenshotsFolder: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
nullable: true,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { qase } from './mocha';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare class CypressQaseReporter extends reporters.Base {
|
|
3
|
-
testCasesForPublishingCount: number;
|
|
4
|
-
private api;
|
|
5
|
-
private pending;
|
|
6
|
-
private shouldPublish;
|
|
7
|
-
private results;
|
|
8
|
-
private options;
|
|
9
|
-
private runId?;
|
|
10
|
-
private isDisabled;
|
|
11
|
-
private resultsForPublishing;
|
|
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;
|
|
19
|
-
private log;
|
|
20
|
-
private addRunnerListeners;
|
|
21
|
-
private checkProject;
|
|
22
|
-
private createRun;
|
|
23
|
-
private checkRun;
|
|
24
|
-
private saveRunId;
|
|
25
|
-
private logTestItem;
|
|
26
|
-
private transformCaseResultToBulkObject;
|
|
27
|
-
}
|
|
1
|
+
import { CypressQaseReporter } from './reporter';
|
|
28
2
|
export = CypressQaseReporter;
|
package/dist/index.js
CHANGED
|
@@ -1,423 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
16
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
17
|
-
return cooked;
|
|
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
|
-
};
|
|
66
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
67
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
68
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
69
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
70
|
-
r[k] = a[j];
|
|
71
|
-
return r;
|
|
72
|
-
};
|
|
73
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
74
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
75
|
-
};
|
|
76
|
-
/* eslint-disable no-console */
|
|
77
|
-
/* eslint-disable camelcase */
|
|
78
|
-
/* eslint-disable @typescript-eslint/unbound-method */
|
|
79
|
-
var src_1 = require("qaseio/dist/src");
|
|
80
|
-
var mocha_1 = require("mocha");
|
|
81
|
-
var child_process_1 = require("child_process");
|
|
82
|
-
var qaseio_1 = require("qaseio");
|
|
83
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
84
|
-
var fs_1 = require("fs");
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
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;
|
|
87
|
-
var Envs;
|
|
88
|
-
(function (Envs) {
|
|
89
|
-
Envs["report"] = "QASE_REPORT";
|
|
90
|
-
Envs["apiToken"] = "QASE_API_TOKEN";
|
|
91
|
-
Envs["basePath"] = "QASE_API_BASE_URL";
|
|
92
|
-
Envs["projectCode"] = "QASE_PROJECT_CODE";
|
|
93
|
-
Envs["runId"] = "QASE_RUN_ID";
|
|
94
|
-
Envs["runName"] = "QASE_RUN_NAME";
|
|
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";
|
|
101
|
-
})(Envs || (Envs = {}));
|
|
102
|
-
var CypressQaseReporter = /** @class */ (function (_super) {
|
|
103
|
-
__extends(CypressQaseReporter, _super);
|
|
104
|
-
function CypressQaseReporter(runner, options) {
|
|
105
|
-
var _this = _super.call(this, runner, options) || this;
|
|
106
|
-
_this.testCasesForPublishingCount = 0;
|
|
107
|
-
_this.pending = [];
|
|
108
|
-
_this.shouldPublish = [];
|
|
109
|
-
_this.results = [];
|
|
110
|
-
_this.isDisabled = false;
|
|
111
|
-
_this.resultsForPublishing = [];
|
|
112
|
-
_this.options = options.reporterOptions;
|
|
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)) {
|
|
119
|
-
return _this;
|
|
120
|
-
}
|
|
121
|
-
_this.log(chalk_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{yellow Current PID: ", "}"], ["{yellow Current PID: ", "}"])), process.pid));
|
|
122
|
-
_this.addRunnerListeners(runner);
|
|
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*/];
|
|
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);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
return String(suite === null || suite === void 0 ? void 0 : suite.title);
|
|
206
|
-
}
|
|
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
|
-
};
|
|
237
|
-
CypressQaseReporter.prototype.log = function (message) {
|
|
238
|
-
var optionalParams = [];
|
|
239
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
240
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
241
|
-
}
|
|
242
|
-
if (this.options.logging) {
|
|
243
|
-
console.log.apply(console, __spreadArrays([chalk_1.default(templateObject_8 || (templateObject_8 = __makeTemplateObject(["{bold {blue qase:}} ", ""], ["{bold {blue qase:}} ", ""])), message)], optionalParams));
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
CypressQaseReporter.prototype.addRunnerListeners = function (runner) {
|
|
247
|
-
var _this = this;
|
|
248
|
-
runner.on(EVENT_TEST_PASS, function (test) {
|
|
249
|
-
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.PASSED);
|
|
250
|
-
});
|
|
251
|
-
runner.on(EVENT_TEST_PENDING, function (test) {
|
|
252
|
-
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.SKIPPED);
|
|
253
|
-
});
|
|
254
|
-
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
255
|
-
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.FAILED);
|
|
256
|
-
});
|
|
257
|
-
runner.addListener(EVENT_RUN_END, function () {
|
|
258
|
-
if (_this.resultsForPublishing.length === 0) {
|
|
259
|
-
_this.log('Nothing to send.');
|
|
260
|
-
}
|
|
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
|
-
});
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
CypressQaseReporter.prototype.checkProject = function (projectCode, cb) {
|
|
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
|
-
});
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
CypressQaseReporter.prototype.createRun = function (name, description, cb) {
|
|
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
|
-
});
|
|
343
|
-
});
|
|
344
|
-
};
|
|
345
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
346
|
-
CypressQaseReporter.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
|
|
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
|
-
})];
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
|
-
CypressQaseReporter.prototype.saveRunId = function (runId) {
|
|
369
|
-
this.runId = runId;
|
|
370
|
-
if (this.runId) {
|
|
371
|
-
while (this.pending.length) {
|
|
372
|
-
this.log("Number of pending: " + this.pending.length);
|
|
373
|
-
var cb = this.pending.shift();
|
|
374
|
-
if (cb) {
|
|
375
|
-
cb(this.runId);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
CypressQaseReporter.prototype.logTestItem = function (test) {
|
|
381
|
-
var map = {
|
|
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),
|
|
385
|
-
};
|
|
386
|
-
if (test.state) {
|
|
387
|
-
this.log(map[test.state]);
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
CypressQaseReporter.prototype.transformCaseResultToBulkObject = function (test, status) {
|
|
391
|
-
var _this = this;
|
|
392
|
-
var _a;
|
|
393
|
-
this.logTestItem(test);
|
|
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),
|
|
408
|
-
};
|
|
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
|
-
}
|
|
418
|
-
};
|
|
419
|
-
return CypressQaseReporter;
|
|
420
|
-
}(mocha_1.reporters.Base));
|
|
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;
|
|
422
|
-
module.exports = CypressQaseReporter;
|
|
423
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
const reporter_1 = require("./reporter");
|
|
3
|
+
module.exports = reporter_1.CypressQaseReporter;
|
package/dist/mocha.d.ts
CHANGED
package/dist/mocha.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var caseIds;
|
|
9
|
-
if (typeof caseId === 'string' || typeof caseId === 'number') {
|
|
10
|
-
caseIds = [caseId.toString()];
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
caseIds = caseId;
|
|
14
|
-
}
|
|
15
|
-
Object.assign(test, { title: testNew.title + " (Qase ID: " + caseIds.join(',') + ")" });
|
|
16
|
-
console.log(test);
|
|
17
|
-
return test;
|
|
18
|
-
},
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.qase = void 0;
|
|
4
|
+
const qase = (caseId, test) => {
|
|
5
|
+
const caseIds = Array.isArray(caseId) ? caseId : [caseId];
|
|
6
|
+
test.title = `${test.title} (Qase ID: ${caseIds.join(',')})`;
|
|
7
|
+
return test;
|
|
19
8
|
};
|
|
20
|
-
|
|
9
|
+
exports.qase = qase;
|
package/dist/options.js
ADDED