cypress-qase-reporter
Advanced tools
Comparing version
import { MochaOptions, Runner, reporters } from 'mocha'; | ||
declare class CypressQaseReporter extends reporters.Base { | ||
testCasesForPublishingCount: number; | ||
private api; | ||
private pending; | ||
private shouldPublish; | ||
private results; | ||
private shouldPublish; | ||
private options; | ||
private runId?; | ||
private isDisabled; | ||
private resultsForPublishing; | ||
constructor(runner: Runner, options: MochaOptions); | ||
private static getEnv; | ||
private static getCaseId; | ||
private static createRunObject; | ||
private static createHeaders; | ||
private static getPackageVersion; | ||
private log; | ||
@@ -15,8 +23,6 @@ private addRunnerListeners; | ||
private checkRun; | ||
private getEnv; | ||
private saveRunId; | ||
private getCaseId; | ||
private logTestItem; | ||
private publishCaseResult; | ||
private transformCaseResultToBulkObject; | ||
} | ||
export = CypressQaseReporter; |
@@ -19,2 +19,49 @@ "use strict"; | ||
}; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
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; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
@@ -31,6 +78,10 @@ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
/* eslint-disable no-console */ | ||
/* eslint-disable camelcase */ | ||
/* eslint-disable @typescript-eslint/unbound-method */ | ||
var src_1 = require("qaseio/dist/src"); | ||
var mocha_1 = require("mocha"); | ||
var models_1 = require("qaseio/dist/src/models"); | ||
var child_process_1 = require("child_process"); | ||
var qaseio_1 = require("qaseio"); | ||
var chalk_1 = __importDefault(require("chalk")); | ||
var fs_1 = require("fs"); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
@@ -42,5 +93,10 @@ 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; | ||
Envs["apiToken"] = "QASE_API_TOKEN"; | ||
Envs["basePath"] = "QASE_API_BASE_URL"; | ||
Envs["runId"] = "QASE_RUN_ID"; | ||
Envs["runName"] = "QASE_RUN_NAME"; | ||
Envs["runDescription"] = "QASE_RUN_DESCRIPTION"; | ||
Envs["environmentId"] = "QASE_ENVIRONMENT_ID"; | ||
Envs["screenshotFolder"] = "QASE_SCREENSHOT_FOLDER"; | ||
Envs["sendScreenshot"] = "QASE_SCREENSHOT_SENDING"; | ||
Envs["runComplete"] = "QASE_RUN_COMPLETE"; | ||
})(Envs || (Envs = {})); | ||
@@ -51,8 +107,11 @@ var CypressQaseReporter = /** @class */ (function (_super) { | ||
var _this = _super.call(this, runner, options) || this; | ||
_this.testCasesForPublishingCount = 0; | ||
_this.pending = []; | ||
_this.shouldPublish = []; | ||
_this.results = []; | ||
_this.shouldPublish = 0; | ||
_this.isDisabled = false; | ||
_this.resultsForPublishing = []; | ||
_this.options = options.reporterOptions; | ||
_this.api = new qaseio_1.QaseApi(_this.options.apiToken || _this.getEnv(Envs.apiToken) || ''); | ||
if (!_this.getEnv(Envs.report)) { | ||
_this.api = new qaseio_1.QaseApi(_this.options.apiToken || CypressQaseReporter.getEnv(Envs.apiToken) || '', CypressQaseReporter.getEnv(Envs.basePath) || _this.options.basePath, CypressQaseReporter.createHeaders()); | ||
if (!CypressQaseReporter.getEnv(Envs.report)) { | ||
return _this; | ||
@@ -62,36 +121,103 @@ } | ||
_this.addRunnerListeners(runner); | ||
_this.checkProject(_this.options.projectCode, function (prjExists) { | ||
if (prjExists) { | ||
_this.log(chalk_1.default(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{green Project ", " exists}"], ["{green Project ", " exists}"])), _this.options.projectCode)); | ||
if (_this.getEnv(Envs.runId) || _this.options.runId) { | ||
_this.saveRunId(_this.getEnv(Envs.runId) || _this.options.runId); | ||
_this.checkRun(_this.runId, function (runExists) { | ||
var run = _this.runId; | ||
if (runExists) { | ||
_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)); | ||
} | ||
else { | ||
_this.log(chalk_1.default(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{red Run ", " does not exist}"], ["{red Run ", " does not exist}"])), run)); | ||
} | ||
}); | ||
void _this.checkProject(_this.options.projectCode, function (prjExists) { return __awaiter(_this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!prjExists) return [3 /*break*/, 5]; | ||
this.log(chalk_1.default(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{green Project ", " exists}"], ["{green Project ", " exists}"])), this.options.projectCode)); | ||
if (!(CypressQaseReporter.getEnv(Envs.runId) || this.options.runId)) return [3 /*break*/, 2]; | ||
this.saveRunId(CypressQaseReporter.getEnv(Envs.runId) || this.options.runId); | ||
return [4 /*yield*/, this.checkRun(this.runId, function (runExists) { | ||
var run = _this.runId; | ||
if (runExists) { | ||
_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)); | ||
} | ||
else { | ||
_this.log(chalk_1.default(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{red Run ", " does not exist}"], ["{red Run ", " does not exist}"])), run)); | ||
} | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 2: | ||
if (!!this.runId) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.createRun(CypressQaseReporter.getEnv(Envs.runName), CypressQaseReporter.getEnv(Envs.runDescription), function (created) { | ||
var _a; | ||
if (created) { | ||
_this.runId = (_a = created.result) === null || _a === void 0 ? void 0 : _a.id; | ||
process.env.QASE_RUN_ID = String(_this === null || _this === void 0 ? void 0 : _this.runId); | ||
_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)); | ||
} | ||
else { | ||
_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)); | ||
_this.isDisabled = true; | ||
} | ||
})]; | ||
case 3: | ||
_a.sent(); | ||
_a.label = 4; | ||
case 4: return [3 /*break*/, 6]; | ||
case 5: | ||
this.log(chalk_1.default(templateObject_7 || (templateObject_7 = __makeTemplateObject(["{red Project ", " does not exist}"], ["{red Project ", " does not exist}"])), this.options.projectCode)); | ||
_a.label = 6; | ||
case 6: return [2 /*return*/]; | ||
} | ||
else if (!_this.runId) { | ||
_this.createRun(_this.getEnv(Envs.runName), _this.getEnv(Envs.runDescription), function (created) { | ||
if (created) { | ||
_this.saveRunId(created.id); | ||
process.env.QASE_RUN_ID = created.id.toString(); | ||
_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)); | ||
} | ||
else { | ||
_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)); | ||
} | ||
}); | ||
}); }); | ||
return _this; | ||
} | ||
CypressQaseReporter.getEnv = function (name) { | ||
return process.env[name]; | ||
}; | ||
CypressQaseReporter.getCaseId = function (test) { | ||
var regexp = /(\(Qase ID: ([\d,]+)\))/; | ||
var results = regexp.exec(test.title); | ||
if (results && results.length === 3) { | ||
return results[2].split(',').map(function (value) { return Number.parseInt(value, 10); }); | ||
} | ||
return []; | ||
}; | ||
CypressQaseReporter.createRunObject = function (name, cases, args) { | ||
return __assign({ title: name, cases: cases }, args); | ||
}; | ||
CypressQaseReporter.createHeaders = function () { | ||
var nodeVersion = process.version, os = process.platform, arch = process.arch; | ||
var npmVersion = child_process_1.execSync('npm -v', { encoding: 'utf8' }).replace(/['"\n]+/g, ''); | ||
var qaseapiVersion = CypressQaseReporter.getPackageVersion('qaseio'); | ||
var cypressVersion = CypressQaseReporter.getPackageVersion('cypress'); | ||
var cypressCaseReporterVersion = this.getPackageVersion('cypress-qase-reporter'); | ||
var xPlatformHeader = "node=" + nodeVersion + "; npm=" + npmVersion + "; os=" + os + "; arch=" + arch; | ||
var xClientHeader = "cypress=" + cypressVersion + "; qase-cypress=" + cypressCaseReporterVersion + "; qaseapi=" + qaseapiVersion; | ||
return { | ||
'X-Client': xClientHeader, | ||
'X-Platform': xPlatformHeader, | ||
}; | ||
}; | ||
CypressQaseReporter.getPackageVersion = function (name) { | ||
var UNDEFINED = 'undefined'; | ||
try { | ||
var pathToPackageJson = require.resolve(name + "/package.json", { | ||
paths: [process.cwd()], | ||
}); | ||
if (pathToPackageJson) { | ||
try { | ||
var packageString = fs_1.readFileSync(pathToPackageJson, { | ||
encoding: 'utf8', | ||
}); | ||
if (packageString) { | ||
var packageObject = JSON.parse(packageString); | ||
return packageObject.version; | ||
} | ||
return UNDEFINED; | ||
} | ||
catch (error) { | ||
return UNDEFINED; | ||
} | ||
} | ||
else { | ||
_this.log(chalk_1.default(templateObject_7 || (templateObject_7 = __makeTemplateObject(["{red Project ", " does not exist}"], ["{red Project ", " does not exist}"])), _this.options.projectCode)); | ||
} | ||
}); | ||
return _this; | ||
} | ||
} | ||
catch (error) { | ||
return UNDEFINED; | ||
} | ||
}; | ||
CypressQaseReporter.prototype.log = function (message) { | ||
@@ -109,26 +235,41 @@ var optionalParams = []; | ||
runner.on(EVENT_TEST_PASS, function (test) { | ||
_this.publishCaseResult(test, models_1.ResultStatus.PASSED); | ||
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.PASSED); | ||
}); | ||
runner.on(EVENT_TEST_PENDING, function (test) { | ||
_this.publishCaseResult(test, models_1.ResultStatus.SKIPPED); | ||
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.SKIPPED); | ||
}); | ||
runner.on(EVENT_TEST_FAIL, function (test) { | ||
_this.publishCaseResult(test, models_1.ResultStatus.FAILED); | ||
_this.transformCaseResultToBulkObject(test, src_1.ResultCreateStatusEnum.FAILED); | ||
}); | ||
runner.on(EVENT_RUN_END, function () { | ||
if (_this.results.length === 0 && _this.shouldPublish === 0) { | ||
_this.log('No testcases were matched. Ensure that your tests are declared correctly.'); | ||
runner.addListener(EVENT_RUN_END, function () { | ||
if (_this.resultsForPublishing.length === 0) { | ||
_this.log('Nothing to send.'); | ||
} | ||
if (_this.runId && _this.shouldPublish !== 0) { | ||
_this.log(chalk_1.default(templateObject_9 || (templateObject_9 = __makeTemplateObject(["{blue Waiting for 30 seconds to publish pending results}"], ["{blue Waiting for 30 seconds to publish pending results}"])))); | ||
var endTime = Date.now() + 30e3; | ||
while ((_this.shouldPublish !== 0) && (Date.now() < endTime)) { | ||
// sleep 500 ms | ||
var sharedArrayBuffer = new SharedArrayBuffer(8); | ||
var int32array = new Int32Array(sharedArrayBuffer); | ||
Atomics.wait(int32array, 0, 0, 500); | ||
} | ||
if (_this.runId && _this.shouldPublish !== 0) { | ||
_this.log(chalk_1.default(templateObject_10 || (templateObject_10 = __makeTemplateObject(["{red Could not send all results for 30 seconds after run. Please contact Qase Team.}"], ["{red Could not send all results for 30 seconds after run. Please contact Qase Team.}"])))); | ||
} | ||
else if (_this.runId) { | ||
var config = { | ||
apiToken: CypressQaseReporter.getEnv(Envs.apiToken) || _this.options.apiToken || '', | ||
basePath: CypressQaseReporter.getEnv(Envs.basePath) || _this.options.basePath, | ||
headers: CypressQaseReporter.createHeaders(), | ||
code: _this.options.projectCode, | ||
runId: Number(_this.runId), | ||
body: { | ||
results: _this.resultsForPublishing, | ||
}, | ||
runComplete: CypressQaseReporter.getEnv(Envs.runComplete) || _this.options.runComplete || false, | ||
}; | ||
var screenshotsConfig = { | ||
screenshotFolder: CypressQaseReporter.getEnv(Envs.screenshotFolder) | ||
|| _this.options.screenshotFolder | ||
|| 'screenshots', | ||
sendScreenshot: CypressQaseReporter.getEnv(Envs.screenshotFolder) | ||
|| _this.options.sendScreenshot | ||
|| false, | ||
}; | ||
child_process_1.spawnSync('node', [__dirname + "/reportBulk.js"], { | ||
stdio: 'inherit', | ||
env: Object.assign(process.env, { | ||
reporting_config: JSON.stringify(config), | ||
screenshots_config: JSON.stringify(screenshotsConfig), | ||
}), | ||
}); | ||
} | ||
@@ -138,36 +279,78 @@ }); | ||
CypressQaseReporter.prototype.checkProject = function (projectCode, cb) { | ||
var _this = this; | ||
this.api.projects.exists(projectCode) | ||
.then(cb) | ||
.catch(function (err) { | ||
_this.log(err); | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var resp, err_1; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 3, , 4]); | ||
return [4 /*yield*/, this.api.projects.getProject(projectCode)]; | ||
case 1: | ||
resp = _b.sent(); | ||
return [4 /*yield*/, cb(Boolean((_a = resp.data.result) === null || _a === void 0 ? void 0 : _a.code))]; | ||
case 2: | ||
_b.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
err_1 = _b.sent(); | ||
this.log(err_1); | ||
this.isDisabled = true; | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
CypressQaseReporter.prototype.createRun = function (name, description, cb) { | ||
var _this = this; | ||
this.api.runs.create(this.options.projectCode, new models_1.RunCreate(name || "Automated run " + new Date().toISOString(), [], | ||
// eslint-disable-next-line camelcase | ||
{ description: description || 'Cypress automated run', is_autotest: true })) | ||
.then(function (res) { return res.data; }) | ||
.then(cb) | ||
.catch(function (err) { | ||
_this.log("Error on creating run " + err); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var environmentId, runObject, res, err_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
environmentId = Number(CypressQaseReporter.getEnv(Envs.environmentId)) || | ||
this.options.environmentId; | ||
runObject = CypressQaseReporter.createRunObject(name || "Automated run " + new Date().toISOString(), [], { | ||
description: description || 'Cypress automated run', | ||
environment_id: environmentId, | ||
is_autotest: true, | ||
}); | ||
return [4 /*yield*/, this.api.runs.createRun(this.options.projectCode, runObject)]; | ||
case 1: | ||
res = _a.sent(); | ||
cb(res.data); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_2 = _a.sent(); | ||
this.log("Error on creating run " + err_2); | ||
this.isDisabled = true; | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
CypressQaseReporter.prototype.checkRun = function (runId, cb) { | ||
var _this = this; | ||
if (runId !== undefined) { | ||
this.api.runs.exists(this.options.projectCode, runId) | ||
.then(cb) | ||
.catch(function (err) { | ||
_this.log("Error on checking run " + err); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
if (runId === undefined) { | ||
cb(false); | ||
return [2 /*return*/]; | ||
} | ||
return [2 /*return*/, this.api.runs | ||
.getRun(this.options.projectCode, Number(runId)) | ||
.then(function (resp) { | ||
var _a, _b; | ||
_this.log("Get run result on checking run " + ((_a = resp.data.result) === null || _a === void 0 ? void 0 : _a.id)); | ||
cb(Boolean((_b = resp.data.result) === null || _b === void 0 ? void 0 : _b.id)); | ||
}) | ||
.catch(function (err) { | ||
_this.log("Error on checking run " + err); | ||
_this.isDisabled = true; | ||
})]; | ||
}); | ||
} | ||
else { | ||
cb(false); | ||
} | ||
}); | ||
}; | ||
CypressQaseReporter.prototype.getEnv = function (name) { | ||
return process.env[name]; | ||
}; | ||
CypressQaseReporter.prototype.saveRunId = function (runId) { | ||
@@ -185,15 +368,7 @@ this.runId = runId; | ||
}; | ||
CypressQaseReporter.prototype.getCaseId = function (test) { | ||
var regexp = /(\(Qase ID: ([\d,]+)\))/; | ||
var results = regexp.exec(test.title); | ||
if (results && results.length === 3) { | ||
return results[2].split(',').map(function (value) { return Number.parseInt(value, 10); }); | ||
} | ||
return []; | ||
}; | ||
CypressQaseReporter.prototype.logTestItem = function (test) { | ||
var map = { | ||
failed: chalk_1.default(templateObject_11 || (templateObject_11 = __makeTemplateObject(["{red Test ", " ", "}"], ["{red Test ", " ", "}"])), test.title, test.state), | ||
passed: chalk_1.default(templateObject_12 || (templateObject_12 = __makeTemplateObject(["{green Test ", " ", "}"], ["{green Test ", " ", "}"])), test.title, test.state), | ||
pending: chalk_1.default(templateObject_13 || (templateObject_13 = __makeTemplateObject(["{blueBright Test ", " ", "}"], ["{blueBright Test ", " ", "}"])), test.title, test.state), | ||
failed: chalk_1.default(templateObject_9 || (templateObject_9 = __makeTemplateObject(["{red Test ", " ", "}"], ["{red Test ", " ", "}"])), test.title, test.state), | ||
passed: chalk_1.default(templateObject_10 || (templateObject_10 = __makeTemplateObject(["{green Test ", " ", "}"], ["{green Test ", " ", "}"])), test.title, test.state), | ||
pending: chalk_1.default(templateObject_11 || (templateObject_11 = __makeTemplateObject(["{blueBright Test ", " ", "}"], ["{blueBright Test ", " ", "}"])), test.title, test.state), | ||
}; | ||
@@ -204,36 +379,18 @@ if (test.state) { | ||
}; | ||
CypressQaseReporter.prototype.publishCaseResult = function (test, status) { | ||
CypressQaseReporter.prototype.transformCaseResultToBulkObject = function (test, status) { | ||
var _this = this; | ||
this.logTestItem(test); | ||
var caseIds = this.getCaseId(test); | ||
var caseIds = CypressQaseReporter.getCaseId(test); | ||
caseIds.forEach(function (caseId) { | ||
_this.shouldPublish++; | ||
var publishTest = function (runId) { | ||
var _a; | ||
if (caseId) { | ||
var add_1 = caseIds.length > 1 ? chalk_1.default(templateObject_14 || (templateObject_14 = __makeTemplateObject([" {white For case ", "}"], [" {white For case ", "}"])), caseId) : ''; | ||
_this.log(chalk_1.default(templateObject_15 || (templateObject_15 = __makeTemplateObject(["{gray Start publishing: ", "}", ""], ["{gray Start publishing: ", "}", ""])), test.title, add_1)); | ||
_this.api.results.create(_this.options.projectCode, runId, new models_1.ResultCreate(caseId, status, { | ||
// eslint-disable-next-line camelcase | ||
time_ms: test.duration, | ||
stacktrace: (_a = test.err) === null || _a === void 0 ? void 0 : _a.stack, | ||
comment: test.err ? test.err.name + ": " + test.err.message : undefined, | ||
})) | ||
.then(function (res) { | ||
_this.results.push({ test: test, result: res.data }); | ||
_this.log(chalk_1.default(templateObject_16 || (templateObject_16 = __makeTemplateObject(["{gray Result published: ", " ", "}", ""], ["{gray Result published: ", " ", "}", ""])), test.title, res.data.hash, add_1)); | ||
_this.shouldPublish--; | ||
}) | ||
.catch(function (err) { | ||
_this.log(err); | ||
_this.shouldPublish--; | ||
}); | ||
} | ||
}; | ||
if (_this.runId) { | ||
publishTest(_this.runId); | ||
var _a; | ||
if (caseId) { | ||
var caseResultBulkObject = { | ||
status: status, | ||
case_id: caseId, | ||
time_ms: test.duration || 0, | ||
stacktrace: (_a = test.err) === null || _a === void 0 ? void 0 : _a.stack, | ||
comment: test.err ? test.err.name + ": " + test.err.message : '', | ||
}; | ||
_this.resultsForPublishing.push(caseResultBulkObject); | ||
} | ||
else { | ||
_this.pending.push(publishTest); | ||
} | ||
}); | ||
@@ -243,4 +400,4 @@ }; | ||
}(mocha_1.reporters.Base)); | ||
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, templateObject_16; | ||
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11; | ||
module.exports = CypressQaseReporter; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
module.exports = { | ||
qase: function (caseId, test) { | ||
if (!test) { | ||
return test; | ||
} | ||
var testNew = test; | ||
@@ -5,0 +8,0 @@ var caseIds; |
{ | ||
"name": "cypress-qase-reporter", | ||
"version": "v1.4.1", | ||
"version": "v1.4.2-alpha.2", | ||
"description": "Qase TMS Cypress Reporter", | ||
@@ -19,3 +19,3 @@ "main": "./dist/index.js", | ||
"scripts": { | ||
"dev": "npm run lint && tsc", | ||
"dev": "npm run lint && tsc && cp ./src/reportBulk.js ./dist", | ||
"dev:watch": "nodemon --exec 'npm run dev || exit 1'", | ||
@@ -33,3 +33,4 @@ "lint": "eslint --fix src/**", | ||
"dependencies": { | ||
"qaseio": "^1.5.0" | ||
"form-data": "^4.0.0", | ||
"qaseio": "^2.0.1" | ||
}, | ||
@@ -36,0 +37,0 @@ "devDependencies": { |
@@ -42,11 +42,33 @@ > # Qase TMS Cypress reporter | ||
``` | ||
You should also have an active item in the project settings at | ||
``` | ||
https://app.qase.io/project/QASE_PROJECT_CODE/settings/options | ||
``` | ||
option in the `Test Runs` block: | ||
``` | ||
Allow submitting results in bulk | ||
``` | ||
If you are going to use several specifications for execution and you have in config | ||
```bash | ||
"runComplete": true | ||
``` | ||
then it is necessary to additionally set in the project settings | ||
``` | ||
Allow to add results for cases in closed runs. | ||
``` | ||
To run tests and create a test run, execute the command: | ||
To run tests and create a test run, execute the command (for example from folder examples): | ||
```bash | ||
QASE_REPORT=1 npx cypress run | ||
``` | ||
or | ||
```bash | ||
npm test | ||
``` | ||
<p align="center"> | ||
<img width="65%" src="./examples/screenshots/screenshot.png"> | ||
</p> | ||
 | ||
A test run will be performed and available at: | ||
A test run will be performed and available at: | ||
``` | ||
@@ -67,2 +89,7 @@ https://app.qase.io/run/QASE_PROJECT_CODE | ||
- `logging` [true/false] - Enabled debug logging from reporter or not | ||
- `environmentId` - To execute with the sending of the envinroment information | ||
- `basePath` - URL Qase.io | ||
- `screenshotFolder` - Folder for save screenshot cypress, | ||
- `sendScreenshot` [true/false] - Permission to send screenshots to Qase TMS | ||
- `runComplete` [true/false] - Permission for automatic completion of the test run | ||
@@ -78,3 +105,4 @@ Example `cypress.json` config: | ||
"runId": 45, | ||
"logging": true | ||
"logging": true, | ||
"basePath": "https://api.qase.io/v1" | ||
} | ||
@@ -93,2 +121,9 @@ } | ||
- `QASE_RUN_DESCRIPTION` - Set custom Run description, when new run is created | ||
- `QASE_API_TOKEN` - Token for API access, you can find more information | ||
[here](https://developers.qase.io/#authentication) | ||
- `QASE_API_BASE_URL` - URL Qase.io, default value `https://api.qase.io/v1` | ||
- `QASE_ENVIRONMENT_ID` - To execute with the sending of the envinroment information | ||
- `QASE_SCREENSHOT_FOLDER` - Folder for save screenshot cypress | ||
- `QASE_SCREENSHOT_SENDING` - Permission to send screenshots to Qase TMS | ||
- `QASE_RUN_COMPLETE` - Permission for automatic completion of the test run | ||
@@ -95,0 +130,0 @@ <!-- references --> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
996524
209.7%20
81.82%4863
1594.43%129
37.23%2
100%1
Infinity%8
300%3
200%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated