Comparing version 0.0.13 to 0.0.14
@@ -19,3 +19,4 @@ export = Loadmill; | ||
run(config: Loadmill.Configuration, paramsOrCallback?: Loadmill.ParamsOrCallback, callback?: Loadmill.Callback): Promise<string>; | ||
wait(loadTestId: string, callback?: Loadmill.Callback): Promise<Loadmill.TestResult>; | ||
runFunctional(config: Loadmill.Configuration, paramsOrCallback?: Loadmill.ParamsOrCallback, callback?: Loadmill.Callback): Promise<Loadmill.TestResult>; | ||
}; |
46
index.js
@@ -30,2 +30,48 @@ "use strict"; | ||
}, | ||
wait: function (loadTestId, callback) { | ||
var _this = this; | ||
var _resolve, _reject; | ||
var intervalId = setInterval(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var result, testResult, err_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, superagent.get("https://www.loadmill.com/api/tests/" + loadTestId) | ||
.auth(token, '')]; | ||
case 1: | ||
result = (_a.sent()).body.result; | ||
if (result) { | ||
clearInterval(intervalId); | ||
testResult = { | ||
id: loadTestId, | ||
passed: result === 'done', | ||
url: "https://www.loadmill.com/app/test/" + loadTestId | ||
}; | ||
if (callback) { | ||
callback(null, testResult); | ||
} | ||
else { | ||
_resolve(testResult); | ||
} | ||
} | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
if (callback) { | ||
callback(err_1, null); | ||
} | ||
else { | ||
_reject(err_1); | ||
} | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, 10 * 1000); | ||
return callback ? null : new Promise(function (resolve, reject) { | ||
_resolve = resolve; | ||
_reject = reject; | ||
}); | ||
}, | ||
runFunctional: function (config, paramsOrCallback, callback) { | ||
@@ -32,0 +78,0 @@ var _this = this; |
{ | ||
"name": "loadmill", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "A node.js module for running load tests and functional tests on loadmill.com", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -46,2 +46,44 @@ import * as fs from 'fs'; | ||
wait(loadTestId: string, callback?: Loadmill.Callback): Promise<Loadmill.TestResult> { | ||
let _resolve, _reject; | ||
const intervalId = setInterval(async () => { | ||
try { | ||
const {body: {result}} = await superagent.get(`https://www.loadmill.com/api/tests/${loadTestId}`) | ||
.auth(token, ''); | ||
if (result) { | ||
clearInterval(intervalId); | ||
const testResult = { | ||
id: loadTestId, | ||
passed: result === 'done', | ||
url: `https://www.loadmill.com/app/test/${loadTestId}`, | ||
}; | ||
if (callback) { | ||
callback(null, testResult); | ||
} | ||
else { | ||
_resolve(testResult); | ||
} | ||
} | ||
} | ||
catch (err) { | ||
if (callback) { | ||
callback(err, null); | ||
} | ||
else { | ||
_reject(err); | ||
} | ||
} | ||
}, | ||
10 * 1000); | ||
return callback ? null! as Promise<any> : new Promise((resolve, reject) => { | ||
_resolve = resolve; | ||
_reject = reject; | ||
}); | ||
}, | ||
runFunctional( | ||
@@ -48,0 +90,0 @@ config: Loadmill.Configuration, |
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
21730
307