Socket
Socket
Sign inDemoInstall

testcafe-reporter-testrail

Package Overview
Dependencies
15
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.1 to 0.8.0

4

lib/config.js

@@ -11,3 +11,3 @@ "use strict";

try {
const data = fs_1.readFileSync(file, { encoding: "utf8" });
const data = (0, fs_1.readFileSync)(file, { encoding: "utf8" });
if (data) {

@@ -23,3 +23,3 @@ return JSON.parse(data);

const prepareConfig = (options = {}) => {
const config = Object.assign(exports.loadJSON(path_1.default.join(process.cwd(), ".testrailrc")), options);
const config = Object.assign((0, exports.loadJSON)(path_1.default.join(process.cwd(), ".testrailrc")), options);
return {

@@ -26,0 +26,0 @@ enabled: process.env.TESTRAIL_ENABLED === "true" || config.enabled || false,

@@ -27,11 +27,12 @@ "use strict";

const prepareRun = async (testrailAPI, config, runName, refs, caseIdList) => {
var _a, _b;
const { projectId, suiteId, runDescription, runId, updateRunTestCases } = config;
let existingRun;
if (runId) {
const { value: returnedRun } = await utils_1.throwOnApiError(testrailAPI.getRun(runId));
const { value: returnedRun } = await (0, utils_1.throwOnApiError)(testrailAPI.getRun(runId));
existingRun = returnedRun;
}
else {
const { value: runs } = await utils_1.throwOnApiError(testrailAPI.getRuns(projectId, { is_completed: 0 }));
existingRun = runs === null || runs === void 0 ? void 0 : runs.find((run) => run.refs === refs);
const { value: runsResult } = await (0, utils_1.throwOnApiError)(testrailAPI.getRuns(projectId, { is_completed: 0 }));
existingRun = (_a = runsResult === null || runsResult === void 0 ? void 0 : runsResult.runs) === null || _a === void 0 ? void 0 : _a.find((run) => run.refs === refs);
}

@@ -47,4 +48,4 @@ if (!updateRunTestCases) {

else if (existingRun) {
const { value: tests } = await utils_1.throwOnApiError(testrailAPI.getTests(existingRun.id));
const currentCaseIds = (tests === null || tests === void 0 ? void 0 : tests.map((test) => test.case_id)) || [];
const { value: testsResult } = await (0, utils_1.throwOnApiError)(testrailAPI.getTests(existingRun.id));
const currentCaseIds = ((_b = testsResult === null || testsResult === void 0 ? void 0 : testsResult.tests) === null || _b === void 0 ? void 0 : _b.map((test) => test.case_id)) || [];
const additionalDescription = "\n" + runDescription;

@@ -55,3 +56,3 @@ const newDescription = existingRun.description

: additionalDescription;
await utils_1.throwOnApiError(testrailAPI.updateRun(existingRun.id, {
await (0, utils_1.throwOnApiError)(testrailAPI.updateRun(existingRun.id, {
description: newDescription,

@@ -72,3 +73,3 @@ case_ids: [...currentCaseIds, ...caseIdList],

};
const { value: newRun } = await utils_1.throwOnApiError(testrailAPI.addRun(projectId, payload));
const { value: newRun } = await (0, utils_1.throwOnApiError)(testrailAPI.addRun(projectId, payload));
console.log(`[TestRail] Test run added successfully: ${runName}`);

@@ -80,10 +81,11 @@ return newRun;

if (config.runCloseAfterDays) {
const { value: runs } = await utils_1.throwOnApiError(testrailAPI.getRuns(config.projectId, { is_completed: 0 }));
const { value: runsResult } = await (0, utils_1.throwOnApiError)(testrailAPI.getRuns(config.projectId, { is_completed: 0 }));
const runs = runsResult.runs || [];
if (runs.length) {
for (let i = 0; i < runs.length; i++) {
const shouldClose = moment_1.default.unix(runs[i].created_on) <=
moment_1.default().subtract(config.runCloseAfterDays, "days");
(0, moment_1.default)().subtract(config.runCloseAfterDays, "days");
if (shouldClose) {
console.log(`[TestRail] Closing test run ${runs[i].id}: ${runs[i].name}`);
await utils_1.throwOnApiError(testrailAPI.closeRun(runs[i].id));
await (0, utils_1.throwOnApiError)(testrailAPI.closeRun(runs[i].id));
}

@@ -143,11 +145,11 @@ }

const { host, user, apiKey, projectId, suiteId } = this.config;
if (config_1.verifyConfig(this.config)) {
if ((0, config_1.verifyConfig)(this.config)) {
try {
if (this.results.length) {
const runName = utils_1.prepareReportName(this.config, this.branch, this.buildNo, this.userAgents);
const refs = utils_1.prepareReference(this.config, this.branch, this.buildNo);
const runName = (0, utils_1.prepareReportName)(this.config, this.branch, this.buildNo, this.userAgents);
const refs = (0, utils_1.prepareReference)(this.config, this.branch, this.buildNo);
const caseIdList = this.results.map((result) => result.case_id);
const testrailAPI = new testrail_js_api_1.TestRail(host, user, apiKey);
const { value: caseList } = await utils_1.throwOnApiError(testrailAPI.getCases(projectId, { suite_id: suiteId }));
const existingCaseIds = caseList.map((item) => item.id);
const { value: caseListResult } = await (0, utils_1.throwOnApiError)(testrailAPI.getCases(projectId, { suite_id: suiteId }));
const existingCaseIds = caseListResult === null || caseListResult === void 0 ? void 0 : caseListResult.cases.map((item) => item.id);
caseIdList.forEach((id) => {

@@ -174,5 +176,6 @@ if (!existingCaseIds.includes(id)) {

const runId = run.id;
const { value: results } = await utils_1.throwOnApiError(testrailAPI.addResultsForCases(runId, resultsToPush));
const { value: tests } = await utils_1.throwOnApiError(testrailAPI.getTests(runId));
await utils_1.uploadScreenshots({
const { value: results } = await (0, utils_1.throwOnApiError)(testrailAPI.addResultsForCases(runId, resultsToPush));
const { value: testsResult } = await (0, utils_1.throwOnApiError)(testrailAPI.getTests(runId));
const tests = testsResult.tests || [];
await (0, utils_1.uploadScreenshots)({
config: this.config,

@@ -185,3 +188,3 @@ tests,

});
await utils_1.uploadVideos({
await (0, utils_1.uploadVideos)({
config: this.config,

@@ -201,3 +204,3 @@ tests,

};
this.config = config_1.prepareConfig();
this.config = (0, config_1.prepareConfig)();
this.branch = process.env[this.config.branchEnv] || "master";

@@ -204,0 +207,0 @@ this.buildNo = process.env[this.config.buildNoEnv] || "unknown";

@@ -15,3 +15,3 @@ "use strict";

for (let j = 0; j < screenshotList.length; j++) {
await utils_1.throwOnApiError(testrailAPI.addAttachmentToResult(result.id, screenshotList[j].screenshotPath));
await (0, utils_1.throwOnApiError)(testrailAPI.addAttachmentToResult(result.id, screenshotList[j].screenshotPath));
}

@@ -18,0 +18,0 @@ }

@@ -15,3 +15,3 @@ "use strict";

for (let j = 0; j < videoList.length; j++) {
await utils_1.throwOnApiError(testrailAPI.addAttachmentToResult(result.id, videoList[j].videoPath));
await (0, utils_1.throwOnApiError)(testrailAPI.addAttachmentToResult(result.id, videoList[j].videoPath));
}

@@ -18,0 +18,0 @@ }

@@ -22,3 +22,3 @@ "use strict";

const prepareReportName = (config, branch, buildNo, userAgents) => {
const date = moment_1.default().format(config.dateFormat);
const date = (0, moment_1.default)().format(config.dateFormat);
return config.runName

@@ -25,0 +25,0 @@ .replace("%BRANCH%", branch)

{
"name": "testcafe-reporter-testrail",
"version": "0.7.1",
"version": "0.8.0",
"description": "Testcafe reporter plugin that automatically publishes test run details to the TestRail system.",

@@ -36,18 +36,18 @@ "main": "lib/index.js",

"moment": "^2.29.1",
"testrail-js-api": "^0.2.1"
"testrail-js-api": "^0.3.0"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/node": "^15.12.2",
"@types/node-fetch": "^2.5.10",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"eslint": "^7.28.0",
"@types/jest": "^27.0.2",
"@types/node": "^16.10.1",
"@types/node-fetch": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^27.0.4",
"prettier": "^2.3.1",
"ts-jest": "^27.0.3",
"typescript": "^4.3.2"
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.2",
"prettier": "^2.4.1",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc