runner-runtime 1.0.49 → 1.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -15
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,6 +3,8 @@ const _ = require('lodash');
|
|
|
3
3
|
const moment = require('moment');
|
|
4
4
|
const aTools = require("apipost-tools");
|
|
5
5
|
const { executeEvent, iterationEvent } = require('./events');
|
|
6
|
+
const { resolve } = require('superagent/lib/request-base');
|
|
7
|
+
const { da } = require('@faker-js/faker');
|
|
6
8
|
const ABORT_RECURSION_ERROR = ['stystemError']; //需要跳出递归的错误
|
|
7
9
|
|
|
8
10
|
// 执行场景
|
|
@@ -44,7 +46,7 @@ const run = async (events, option, callback) => {
|
|
|
44
46
|
await executeEvent(event, _.assign(eventOptions, { iterationData: {} }), callback, eventRuntimeData, eventResultList);
|
|
45
47
|
} catch (e) {
|
|
46
48
|
if (_.includes(ABORT_RECURSION_ERROR, e?.action)) {
|
|
47
|
-
throw
|
|
49
|
+
throw (e);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -85,22 +87,24 @@ const run = async (events, option, callback) => {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
const request2HAR =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
const request2HAR = (events, option) => {
|
|
91
|
+
return new Promise(async (resolve, reject) => {
|
|
92
|
+
const eventOptions = _.pick(option, ["scene", "lang", "project", "env", "globals", "cookies", "system_configs", "custom_functions", "collection", "database_configs", "enable_sandbox", "sleep", "name", "testing_id"]);
|
|
93
|
+
const eventRuntimeData = {
|
|
94
|
+
variables: {}
|
|
95
|
+
};
|
|
96
|
+
const eventResultList = [];
|
|
97
|
+
const event = _.first(events);
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if (_.isObject(event) && _.has(event, 'type')) {
|
|
100
|
+
try {
|
|
101
|
+
await executeEvent(event, _.assign(eventOptions, { scene: 'get_parsed_request' }), (data) => {
|
|
102
|
+
resolve(data)
|
|
103
|
+
}, eventRuntimeData, eventResultList);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
reject(e)
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
|
-
}
|
|
108
|
+
})
|
|
105
109
|
}
|
|
106
110
|
module.exports = { run, request2HAR }
|