Comparing version 1.1.1 to 1.1.2
@@ -53,4 +53,4 @@ import './polyfills'; | ||
SUITE = "test-suite", | ||
LOCAL = "local", | ||
LOCAL = "local" | ||
} | ||
} |
@@ -53,4 +53,4 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var resolve, reject, testDef, apiUrl, webUrl, intervalId; | ||
var _this = this; | ||
var resolve, reject, testDef, apiUrl, webUrl, intervalId; | ||
return tslib_1.__generator(this, function (_a) { | ||
@@ -75,3 +75,3 @@ testDef = typeof testDefOrId === 'string' ? { | ||
clearInterval(intervalId); | ||
testResult = tslib_1.__assign({}, testDef, { url: webUrl, passed: isTestPassed(body, testDef.type) }); | ||
testResult = tslib_1.__assign({}, testDef, { url: webUrl, passed: isTestPassed(body, testDef.type), flowRuns: reductFlowRunsData(body.testSuiteFlowRuns) }); | ||
if (callback) { | ||
@@ -180,7 +180,7 @@ callback(null, testResult); | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var overrideParameters, suiteId, additionalDescription, labels; | ||
var _this = this; | ||
var overrideParameters, suiteId, additionalDescription, labels; | ||
return tslib_1.__generator(this, function (_a) { | ||
overrideParameters = typeof paramsOrCallback !== 'function' ? paramsOrCallback : {}; | ||
if (typeof suite === 'string') { | ||
if (typeof suite === 'string') { // need to depricate the option of string in 2.x version | ||
suiteId = suite; | ||
@@ -302,3 +302,3 @@ } | ||
return body.status === "PASSED"; | ||
default://load | ||
default: //load | ||
return body.result === 'done'; | ||
@@ -321,3 +321,3 @@ } | ||
return prefix + "/test-suites-runs/" + id; | ||
default://load | ||
default: //load | ||
return prefix + "/tests/" + id; | ||
@@ -334,6 +334,11 @@ } | ||
return prefix + "/api-tests/test-suite-runs/" + id; | ||
default://load | ||
default: //load | ||
return prefix + "/test/" + id; | ||
} | ||
} | ||
function reductFlowRunsData(flowRuns) { | ||
if (flowRuns) { | ||
return flowRuns.map(function (f) { return ({ description: f.description, status: f.status }); }); | ||
} | ||
} | ||
function wrap(asyncFunction, paramsOrCallback) { | ||
@@ -340,0 +345,0 @@ var promise = asyncFunction(); |
@@ -21,2 +21,3 @@ "use strict"; | ||
.option("-v, --verbose", "Print out extra information for debugging.") | ||
.option("-r, --report", "Print out Test Suite Flow Runs report when the suite has ended.") | ||
.option("--colors", "Print test results in color") | ||
@@ -30,7 +31,7 @@ .parse(process.argv); | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var wait, bail, async, quiet, token, verbose, colors, local, loadTest, testSuite, additionalDescription, labels, _a, input, rawParams, logger, parameters, loadmill, res, suite, running, testSuiteRunId, e_1, extInfo, fileOrFolder, listOfFiles, _i, listOfFiles_1, file, res, id, method; | ||
var wait, bail, async, quiet, token, verbose, colors, report, local, loadTest, testSuite, additionalDescription, labels, _a, input, rawParams, logger, parameters, loadmill, res, flowRuns, suite, running, testSuiteRunId, e_1, extInfo, fileOrFolder, listOfFiles, _i, listOfFiles_1, file, res, id, method; | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
wait = program.wait, bail = program.bail, async = program.async, quiet = program.quiet, token = program.token, verbose = program.verbose, colors = program.colors, local = program.local, loadTest = program.loadTest, testSuite = program.testSuite, additionalDescription = program.additionalDescription, labels = program.labels, _a = program.args, input = _a[0], rawParams = _a.slice(1); | ||
wait = program.wait, bail = program.bail, async = program.async, quiet = program.quiet, token = program.token, verbose = program.verbose, colors = program.colors, report = program.report, local = program.local, loadTest = program.loadTest, testSuite = program.testSuite, additionalDescription = program.additionalDescription, labels = program.labels, _a = program.args, input = _a[0], rawParams = _a.slice(1); | ||
logger = new utils_1.Logger(verbose, colors); | ||
@@ -52,2 +53,3 @@ if (!token) { | ||
verbose: verbose, | ||
report: report, | ||
loadTest: loadTest, | ||
@@ -62,6 +64,6 @@ testSuite: testSuite, | ||
if (!testSuite) return [3 /*break*/, 9]; | ||
if (!utils_1.isUUID(input)) { | ||
if (!utils_1.isUUID(input)) { //if test suite flag is on then the input should be uuid | ||
validationFailed("Test suite run flag is on but no valid test suite id was provided."); | ||
} | ||
res = void 0; | ||
res = void 0, flowRuns = void 0; | ||
suite = { id: input, additionalDescription: additionalDescription, labels: utils_1.convertStrToArr(labels) }; | ||
@@ -81,2 +83,4 @@ _b.label = 1; | ||
res = _b.sent(); | ||
flowRuns = res.flowRuns; | ||
delete res.flowRuns; // dont want to print these in getObjectAsString | ||
_b.label = 4; | ||
@@ -87,2 +91,5 @@ case 4: | ||
} | ||
if (report && flowRuns) { | ||
utils_1.printFlowRunsReport(flowRuns, logger, colors); | ||
} | ||
if (res && res.passed != null && !res.passed) { | ||
@@ -89,0 +96,0 @@ testFailed(logger, "Test suite with id " + input + " failed", bail); |
@@ -39,2 +39,14 @@ "use strict"; | ||
}; | ||
var coloredFlowLine = function (status, colors) { | ||
if (!colors) { | ||
return status; | ||
} | ||
return "" + getStatusColor(status) + status + CLI_COLORS.DEFAULT; | ||
}; | ||
exports.printFlowRunsReport = function (testSuiteFlowRuns, logger, colors) { | ||
if (testSuiteFlowRuns) { | ||
logger.log("Test Suite Flow Runs report:"); | ||
testSuiteFlowRuns.map(function (f) { return logger.log("Flow " + f.description + " - " + coloredFlowLine(f.status, colors)); }); | ||
} | ||
}; | ||
exports.convertStrToArr = function (strWithCommas) { | ||
@@ -135,3 +147,3 @@ return typeof strWithCommas !== "string" ? null : strWithCommas.split(","); | ||
if (_this.colors) { | ||
console.log('\x1b[31m', err, '\x1b[0m'); | ||
console.log(CLI_COLORS.RED, err, CLI_COLORS.DEFAULT); | ||
} | ||
@@ -155,1 +167,19 @@ else { | ||
exports.Logger = Logger; | ||
var getStatusColor = function (status) { | ||
switch (status) { | ||
case "PASSED": | ||
return CLI_COLORS.GREEN; | ||
case "FAILED": | ||
return CLI_COLORS.RED; | ||
case "STOPPED": | ||
return CLI_COLORS.GREY; | ||
default: | ||
return CLI_COLORS.DEFAULT; | ||
} | ||
}; | ||
var CLI_COLORS = { | ||
RED: '\x1b[31m', | ||
GREEN: '\x1b[32m', | ||
GREY: '\x1b[90m', | ||
DEFAULT: '\x1b[0m' | ||
}; |
{ | ||
"name": "loadmill", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A node.js module for running load tests and functional tests on loadmill.com", | ||
@@ -24,4 +24,11 @@ "keywords": [ | ||
"prepare": "tsc && rm -f lib/loadmill.d.ts lib/utils.d.ts lib/polyfills.d.ts", | ||
"test": "mocha" | ||
"test": "npm run test-npm && npm run test-cli", | ||
"test-npm": "mocha", | ||
"test-cli": "./test/test-cli.sh" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm test" | ||
} | ||
}, | ||
"dependencies": { | ||
@@ -48,5 +55,7 @@ "bluebird": "^3.4.7", | ||
"@types/node": "^9.4.7", | ||
"typescript": "^2.7.2", | ||
"mocha": "^7.0.0" | ||
"dotenv": "^8.2.0", | ||
"husky": "^4.2.1", | ||
"mocha": "^7.0.0", | ||
"typescript": "^2.7.2" | ||
} | ||
} |
@@ -190,2 +190,3 @@ # Loadmill | ||
- `-v, --verbose` Print out extra information for debugging (trumps `-q`). In case of an error will print the entire test's requests otherwise will print only the failed request. | ||
- `-r, --report` Print out Test Suite Flow Runs report when the suite has ended. | ||
- `--colors` Print test results in color. |
@@ -62,2 +62,3 @@ import './polyfills' | ||
passed: isTestPassed(body, testDef.type), | ||
flowRuns: reductFlowRunsData(body.testSuiteFlowRuns) | ||
}; | ||
@@ -353,2 +354,8 @@ | ||
function reductFlowRunsData(flowRuns) { | ||
if (flowRuns) { | ||
return flowRuns.map( f => ({description: f.description, status: f.status })); | ||
} | ||
} | ||
function wrap(asyncFunction, paramsOrCallback?: Loadmill.ParamsOrCallback) { | ||
@@ -355,0 +362,0 @@ const promise = asyncFunction(); |
import * as Loadmill from './index'; | ||
import * as program from 'commander'; | ||
import { getJSONFilesInFolderRecursively, Logger, isUUID, getObjectAsString, convertStrToArr } from './utils'; | ||
import { getJSONFilesInFolderRecursively, Logger, isUUID, | ||
getObjectAsString, convertStrToArr, printFlowRunsReport } from './utils'; | ||
@@ -21,2 +22,3 @@ program | ||
.option("-v, --verbose", "Print out extra information for debugging.") | ||
.option("-r, --report", "Print out Test Suite Flow Runs report when the suite has ended.") | ||
.option("--colors", "Print test results in color") | ||
@@ -41,2 +43,3 @@ .parse(process.argv); | ||
colors, | ||
report, | ||
local, | ||
@@ -70,2 +73,3 @@ loadTest, | ||
verbose, | ||
report, | ||
loadTest, | ||
@@ -85,3 +89,3 @@ testSuite, | ||
} | ||
let res; | ||
let res, flowRuns; | ||
const suite: Loadmill.TestSuiteDef = { id: input, additionalDescription, labels: convertStrToArr(labels) }; | ||
@@ -98,2 +102,4 @@ try { | ||
res = await loadmill.wait(running); | ||
flowRuns = res.flowRuns; | ||
delete res.flowRuns; // dont want to print these in getObjectAsString | ||
} | ||
@@ -105,2 +111,6 @@ | ||
if(report && flowRuns) { | ||
printFlowRunsReport(flowRuns, logger, colors); | ||
} | ||
if (res && res.passed != null && !res.passed) { | ||
@@ -107,0 +117,0 @@ testFailed(logger, `Test suite with id ${input} failed`, bail); |
@@ -46,2 +46,17 @@ import * as fs from "fs"; | ||
const coloredFlowLine = (status, colors) => { | ||
if (!colors) { | ||
return status; | ||
} | ||
return `${getStatusColor(status)}${status}${CLI_COLORS.DEFAULT}`; | ||
} | ||
export const printFlowRunsReport = (testSuiteFlowRuns, logger, colors) => { | ||
if (testSuiteFlowRuns) { | ||
logger.log("Test Suite Flow Runs report:"); | ||
testSuiteFlowRuns.map( | ||
f => logger.log(`Flow ${f.description} - ${coloredFlowLine(f.status, colors)}`)); | ||
} | ||
} | ||
export const convertStrToArr = (strWithCommas) => { | ||
@@ -152,5 +167,5 @@ return typeof strWithCommas !== "string" ? null : strWithCommas.split(","); | ||
if (this.colors) { | ||
console.log('\x1b[31m', err, '\x1b[0m') | ||
console.log(CLI_COLORS.RED, err, CLI_COLORS.DEFAULT); | ||
} else { | ||
console.log(err) | ||
console.log(err); | ||
} | ||
@@ -160,1 +175,21 @@ }; | ||
} | ||
const getStatusColor = (status) => { | ||
switch (status) { | ||
case "PASSED": | ||
return CLI_COLORS.GREEN; | ||
case "FAILED": | ||
return CLI_COLORS.RED; | ||
case "STOPPED": | ||
return CLI_COLORS.GREY; | ||
default: | ||
return CLI_COLORS.DEFAULT; | ||
} | ||
} | ||
const CLI_COLORS = { | ||
RED: '\x1b[31m', | ||
GREEN: '\x1b[32m', | ||
GREY: '\x1b[90m', | ||
DEFAULT: '\x1b[0m' | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
89316
1563
191
4
5