Comparing version 4.2.4 to 4.2.5
@@ -66,2 +66,4 @@ import './polyfills'; | ||
flowStatus: FLOW_STATUS; | ||
duration: number; | ||
retries?: number; | ||
} | ||
@@ -68,0 +70,0 @@ type Configuration = object | string | any; |
@@ -38,3 +38,3 @@ "use strict"; | ||
if (!(testDef.type === Loadmill.TYPES.TEST_PLAN)) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, superagent.get(apiUrl + "?fetchAllFlows=true").auth(token, '')]; | ||
return [4 /*yield*/, superagent.get(apiUrl, { fetchAllFlows: true, groupFlowAttempts: true }).auth(token, '')]; | ||
case 2: | ||
@@ -256,8 +256,17 @@ bodyWithFlows = (_a.sent()).body; | ||
if (Array.isArray(s.testSuiteFlowRuns)) { | ||
suiteRun.flowRuns = s.testSuiteFlowRuns.map(function (fr) { return ({ | ||
id: fr.id, | ||
status: fr.status, | ||
description: fr.description, | ||
flowStatus: fr.testSuiteFlowStatus | ||
}); }); | ||
suiteRun.flowRuns = s.testSuiteFlowRuns.map(function (fr) { | ||
var _a; | ||
var flowRun = { | ||
id: fr.id, | ||
status: fr.status, | ||
description: fr.description, | ||
flowStatus: fr.testSuiteFlowStatus, | ||
duration: (fr.endTime - fr.startTime) || 0 | ||
}; | ||
if ((_a = fr.runs) === null || _a === void 0 ? void 0 : _a.length) { | ||
flowRun.retries = fr.runs.length - 1; | ||
flowRun.duration = fr.runs[fr.runs.length - 1].endTime - fr.runs[0].startTime; | ||
} | ||
return flowRun; | ||
}); | ||
} | ||
@@ -264,0 +273,0 @@ return suiteRun; |
@@ -238,2 +238,9 @@ "use strict"; | ||
} | ||
function generateCodeBlock(s, f) { | ||
var res = "URL: " + getFlowRunWebURL(s, f); | ||
if (f.retries) { | ||
res += "\nRetries: " + f.retries; | ||
} | ||
return res; | ||
} | ||
function getFlowRunWebURL(s, f) { | ||
@@ -270,3 +277,3 @@ return testingServer + "/app/api-tests/test-suite-runs/" + s.id + "/flows/" + f.id; | ||
flowData = (_a.sent()).body; | ||
hasPassed = flow.status === 'PASSED'; | ||
hasPassed = _hasPassed(flow); | ||
hasFailed = flow.status === 'FAILED'; | ||
@@ -277,3 +284,3 @@ res = { | ||
"timedOut": false, | ||
"duration": (flowData.endTime - flowData.startTime) || 0, | ||
"duration": flow.duration, | ||
"state": hasPassed ? 'passed' : 'failed', | ||
@@ -285,3 +292,3 @@ "pass": hasPassed, | ||
"pending": false, | ||
"code": getFlowRunWebURL(suite, flow), | ||
"code": generateCodeBlock(suite, flow), | ||
"err": hasFailed ? toMochawesomeFailedFlow(flowData) : {}, | ||
@@ -301,3 +308,3 @@ "uuid": flow.id | ||
flows = suite.flowRuns || []; | ||
passedFlows = flows.filter(function (f) { return f.status === 'PASSED'; }).map(function (f) { return f.id; }); | ||
passedFlows = flows.filter(function (f) { return _hasPassed(f); }).map(function (f) { return f.id; }); | ||
failedFlows = flows.filter(function (f) { return f.status === 'FAILED'; }).map(function (f) { return f.id; }); | ||
@@ -309,3 +316,3 @@ limit = pLimit(3); | ||
_a = "tests"; | ||
return [4 /*yield*/, Promise.all(flows.filter(function (flow) { return ['PASSED', 'FAILED'].includes(flow.status); }) | ||
return [4 /*yield*/, Promise.all(flows.filter(function (flow) { return _hasPassed(flow) || flow.status === 'FAILED'; }) | ||
.map(function (f) { return limit(function () { return flowToMochawesone(suite, f, token); }); }))]; | ||
@@ -442,1 +449,4 @@ case 1: return [2 /*return*/, (_b[_a] = _c.sent(), | ||
} | ||
var _hasPassed = function (flow) { return flow.status === 'PASSED' || _isFlaky(flow); }; | ||
// check by status alone is not enough because of backward compatibility | ||
var _isFlaky = function (flow) { return flow.status === 'FLAKY' && !!flow.retries; }; |
{ | ||
"name": "loadmill", | ||
"version": "4.2.4", | ||
"version": "4.2.5", | ||
"description": "A node.js module for running load tests and functional tests on loadmill.com", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -49,3 +49,3 @@ import './polyfills' | ||
if (testDef.type === Loadmill.TYPES.TEST_PLAN) { | ||
const { body: bodyWithFlows } = await superagent.get(`${apiUrl}?fetchAllFlows=true`).auth(token, ''); | ||
const { body: bodyWithFlows } = await superagent.get(apiUrl, { fetchAllFlows: true, groupFlowAttempts: true }).auth(token, ''); | ||
body = bodyWithFlows; | ||
@@ -269,8 +269,18 @@ } | ||
if (Array.isArray(s.testSuiteFlowRuns)) { | ||
suiteRun.flowRuns = s.testSuiteFlowRuns.map(fr => ({ | ||
id: fr.id, | ||
status: fr.status, | ||
description: fr.description, | ||
flowStatus: fr.testSuiteFlowStatus | ||
})); | ||
suiteRun.flowRuns = s.testSuiteFlowRuns.map(fr => { | ||
const flowRun: Loadmill.FlowRun = { | ||
id: fr.id, | ||
status: fr.status, | ||
description: fr.description, | ||
flowStatus: fr.testSuiteFlowStatus, | ||
duration: (fr.endTime - fr.startTime) || 0, | ||
}; | ||
if (fr.runs?.length) { | ||
flowRun.retries = fr.runs.length - 1; | ||
flowRun.duration = fr.runs[fr.runs.length - 1].endTime - fr.runs[0].startTime; | ||
} | ||
return flowRun; | ||
}); | ||
} | ||
@@ -382,2 +392,4 @@ | ||
flowStatus: FLOW_STATUS; | ||
duration: number; | ||
retries?: number; | ||
} | ||
@@ -384,0 +396,0 @@ |
@@ -261,2 +261,10 @@ import * as fs from "fs"; | ||
function generateCodeBlock(s: Loadmill.TestResult, f: Loadmill.FlowRun) { | ||
let res = `URL: ${getFlowRunWebURL(s, f)}`; | ||
if (f.retries) { | ||
res += `\nRetries: ${f.retries}`; | ||
} | ||
return res; | ||
} | ||
function getFlowRunWebURL(s: Loadmill.TestResult, f: Loadmill.FlowRun) { | ||
@@ -294,3 +302,3 @@ return `${testingServer}/app/api-tests/test-suite-runs/${s.id}/flows/${f.id}`; | ||
const hasPassed = flow.status === 'PASSED'; | ||
const hasPassed = _hasPassed(flow); | ||
const hasFailed = flow.status === 'FAILED'; | ||
@@ -302,3 +310,3 @@ const res = | ||
"timedOut": false, | ||
"duration": (flowData.endTime - flowData.startTime) || 0, | ||
"duration": flow.duration, | ||
"state": hasPassed ? 'passed' : 'failed', | ||
@@ -310,3 +318,3 @@ "pass": hasPassed, | ||
"pending": false, | ||
"code": getFlowRunWebURL(suite, flow), | ||
"code": generateCodeBlock(suite, flow), | ||
"err": hasFailed ? toMochawesomeFailedFlow(flowData) : {}, | ||
@@ -321,3 +329,3 @@ "uuid": flow.id | ||
const flows = suite.flowRuns || []; | ||
const passedFlows = flows.filter(f => f.status === 'PASSED').map(f => f.id); | ||
const passedFlows = flows.filter(f => _hasPassed(f)).map(f => f.id); | ||
const failedFlows = flows.filter(f => f.status === 'FAILED').map(f => f.id); | ||
@@ -330,3 +338,3 @@ | ||
"tests": await Promise.all( | ||
flows.filter(flow => ['PASSED', 'FAILED'].includes(flow.status)) | ||
flows.filter(flow => _hasPassed(flow) || flow.status === 'FAILED') | ||
.map(f => limit(() => flowToMochawesone(suite, f, token))) | ||
@@ -427,1 +435,6 @@ ), | ||
} | ||
const _hasPassed = (flow: Loadmill.FlowRun): boolean => flow.status === 'PASSED' || _isFlaky(flow); | ||
// check by status alone is not enough because of backward compatibility | ||
const _isFlaky = (flow: Loadmill.FlowRun): boolean => flow.status === 'FLAKY' && !!flow.retries; |
132586
2686