Skip to content

Commit 6f83987

Browse files
Merge pull request #50 from RapidAPI/staging
ci-publish-package
2 parents 9980a08 + cab7aac commit 6f83987

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rapidapi/testing-worker",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "A RapidAPI Testing worker CLI",
55
"private": false,
66
"license": "MIT",

src/models/TestExecutable.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class TestExecutable {
6363
let _apiCalls = [];
6464
let _actionReports = [];
6565
let timeoutId;
66+
let currentActionIndex = 0;
6667

6768
// TIMING
6869
const { performance } = require("perf_hooks");
@@ -90,7 +91,7 @@ class TestExecutable {
9091
let result = { contextWrites: [], apiCalls: [], actionReports: [] };
9192
//2. evaluate action
9293
try {
93-
result = Object.assign(result, await action.eval(context, stepTimeoutSeconds));
94+
result = Object.assign(result, await action.eval(context, timeoutSeconds, stepTimeoutSeconds));
9495
} catch (e) {
9596
result.actionReports = [
9697
{
@@ -116,24 +117,40 @@ class TestExecutable {
116117
// this does need to bubble to the top for child tests to be correctly scoped
117118
// into a parent.
118119
totalContextWrites.push(...result.contextWrites);
120+
currentActionIndex += 1;
119121
}
120122
// Clear the timeout or else the lambda will hang around until it finishes which is not
121123
// ideal for default workers without a frequency value.
122124
clearTimeout(timeoutId);
123125
return FINISHED_EXECUTION;
124126
})();
125127
let result = await Promise.race([timeoutTimer, testExecution]);
126-
//TIMING
128+
// TIMING
127129
const t1 = performance.now();
128130
const elapsedTime = t1 - t0;
129131

130-
//OVERALL SUCCESS
132+
// OVERALL SUCCESS
131133
let success = _actionReports.filter((a) => a.success == false).length == 0 && result === FINISHED_EXECUTION;
134+
let _finalReport = _actionReports;
135+
136+
if (result === TIMEOUT) {
137+
const finishedStepsTotalTime = _finalReport.reduce((a, c) => a + c.time, 0);
138+
139+
// Add a failed step for the test timeout limit and inform the user that subsequent steps
140+
// have been skipped
141+
_finalReport.push({
142+
action: actions[currentActionIndex].action,
143+
success: false,
144+
shortSummary: `Test exceeded timeout limit of ${timeoutSeconds}s. Subsequent steps skipped.`,
145+
longSummary: null,
146+
time: elapsedTime - finishedStepsTotalTime, // time delta is where the step terminated due to timeout
147+
});
148+
}
132149

133150
return {
134151
contextWrites: totalContextWrites, // optional
135152
apiCalls: _apiCalls,
136-
actionReports: _actionReports,
153+
actionReports: _finalReport,
137154
elapsedTime,
138155
success,
139156
timedOut: result === TIMEOUT,

src/models/actions/Http.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class Http extends BaseAction {
3838
return requestObj;
3939
}
4040

41-
async eval(context, stepTimeoutSeconds = 15) {
41+
// eslint-disable-next-line no-unused-vars
42+
async eval(context, timeoutSeconds = 300, stepTimeoutSeconds = 15) {
4243
// fetch axios instance from context or create one if does not exist
4344
// this "shared" axios instance is used to ensure that cookies are properly passed between requests
4445
let transport;

0 commit comments

Comments
 (0)