runner-runtime 1.0.84 → 1.0.86
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/events/api.js +7 -6
- package/index.js +34 -2
- package/libs/utils.js +2 -1
- package/package.json +3 -3
- package/tmp/request.js +636 -1346
package/events/api.js
CHANGED
|
@@ -50,6 +50,7 @@ const convert2PostmanRequest = (request, option) => {
|
|
|
50
50
|
const queryAddEqual = _.toInteger(
|
|
51
51
|
_.get(request, "request.query.query_add_equal") || -1
|
|
52
52
|
);
|
|
53
|
+
|
|
53
54
|
_.forEach(_.get(request, "request.query.parameter"), (item) => {
|
|
54
55
|
if (_.isObject(item) && item?.is_checked > 0) {
|
|
55
56
|
let { key, value, schema } = item;
|
|
@@ -57,7 +58,7 @@ const convert2PostmanRequest = (request, option) => {
|
|
|
57
58
|
value = String(autoReplaceMockVar(value));
|
|
58
59
|
|
|
59
60
|
if (value == '' && _.isObject(schema)) {
|
|
60
|
-
const tmpValue = jsfGenerate(schema, [], option?.lang);
|
|
61
|
+
const tmpValue = jsfGenerate(schema, [], option?.lang, option?.custom_functions || {});
|
|
61
62
|
|
|
62
63
|
if (!_.isUndefined(tmpValue)) {
|
|
63
64
|
value = tmpValue;
|
|
@@ -100,7 +101,7 @@ const convert2PostmanRequest = (request, option) => {
|
|
|
100
101
|
value = autoReplaceMockVar(value);
|
|
101
102
|
|
|
102
103
|
if (value == '' && _.isObject(schema)) {
|
|
103
|
-
const tmpValue = jsfGenerate(schema, [], option?.lang);
|
|
104
|
+
const tmpValue = jsfGenerate(schema, [], option?.lang, option?.custom_functions || {});
|
|
104
105
|
|
|
105
106
|
if (!_.isUndefined(tmpValue)) {
|
|
106
107
|
value = tmpValue;
|
|
@@ -287,7 +288,7 @@ const convert2PostmanRequest = (request, option) => {
|
|
|
287
288
|
value = autoReplaceMockVar(value);
|
|
288
289
|
|
|
289
290
|
if (value == '' && _.isObject(schema)) {
|
|
290
|
-
const tmpValue = jsfGenerate(schema, [], option?.lang);
|
|
291
|
+
const tmpValue = jsfGenerate(schema, [], option?.lang, option?.custom_functions || {});
|
|
291
292
|
|
|
292
293
|
if (!_.isUndefined(tmpValue)) {
|
|
293
294
|
value = tmpValue;
|
|
@@ -377,7 +378,7 @@ const convert2PostmanRequest = (request, option) => {
|
|
|
377
378
|
let value = autoReplaceMockVar(item.value);
|
|
378
379
|
|
|
379
380
|
if (value == '' && _.isObject(item?.schema)) {
|
|
380
|
-
const tmpValue = jsfGenerate(item?.schema, [], option?.lang);
|
|
381
|
+
const tmpValue = jsfGenerate(item?.schema, [], option?.lang, option?.custom_functions || {});
|
|
381
382
|
|
|
382
383
|
if (!_.isUndefined(tmpValue)) {
|
|
383
384
|
value = tmpValue;
|
|
@@ -473,7 +474,7 @@ const convert2PostmanRequest = (request, option) => {
|
|
|
473
474
|
value = autoReplaceMockVar(value);
|
|
474
475
|
|
|
475
476
|
if (value == '' && _.isObject(schema)) {
|
|
476
|
-
const tmpValue = jsfGenerate(schema, [], option?.lang);
|
|
477
|
+
const tmpValue = jsfGenerate(schema, [], option?.lang, option?.custom_functions || {});
|
|
477
478
|
|
|
478
479
|
if (!_.isUndefined(tmpValue)) {
|
|
479
480
|
value = tmpValue;
|
|
@@ -2470,7 +2471,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
|
|
|
2470
2471
|
},
|
|
2471
2472
|
|
|
2472
2473
|
responseData(cursor, data) {
|
|
2473
|
-
if (!_.includes(['get_parsed_request'], scene)) {
|
|
2474
|
+
if (!_.includes(['get_parsed_request'], scene) && requestJson?.target_type === 'sse') {
|
|
2474
2475
|
callback({
|
|
2475
2476
|
action: "sse",
|
|
2476
2477
|
data: {
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const { repeatArrayToLength, formatAutotestReport, formatAutotestReportList } = require('./libs/utils');
|
|
1
|
+
const { repeatArrayToLength, formatAutotestReport, formatAutotestReportList, getInsideVariables } = require('./libs/utils');
|
|
2
2
|
const _ = require('lodash');
|
|
3
|
+
const { mockExp } = require('exp-mock');
|
|
3
4
|
const aTools = require("apipost-tools");
|
|
4
5
|
const { executeEvent, iterationEvent } = require('./events');
|
|
5
6
|
const ABORT_RECURSION_ERROR = ['systemError']; //需要跳出递归的错误
|
|
@@ -13,7 +14,7 @@ const run = async (events, option, callback) => {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const tempEvents = _.cloneDeep(_.flatten(new Array(scene == 'auto_test' ? _.max([_.toInteger(iterationCount), 1]) : 1).fill(events))) || [];
|
|
16
|
-
const
|
|
17
|
+
const iterationDataArrTemp = _.flatMap(repeatArrayToLength(_.cloneDeep(iterationData), _.max([_.toInteger(iterationCount), 1])), (element) => _.times(_.size(events), () => element));
|
|
17
18
|
const eventOptions = _.pick(option, ["scene", "lang", "project", "env", "globals", "cookies", "system_configs", "custom_functions", "collection", "database_configs", "enable_sandbox", "sleep", "name", "testing_id"]);
|
|
18
19
|
|
|
19
20
|
// 初始化变量
|
|
@@ -28,6 +29,37 @@ const run = async (events, option, callback) => {
|
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
|
|
32
|
+
const iterationDataArr = [];
|
|
33
|
+
if (scene != 'http_request') {
|
|
34
|
+
// 解析测试数据
|
|
35
|
+
const regex = /{{([^}]+)}}/g;
|
|
36
|
+
_.forEach(iterationDataArrTemp, (obj, index) => {
|
|
37
|
+
const cloneObj = _.cloneDeep(obj);
|
|
38
|
+
if (_.isObject(obj) && !_.isEmpty(obj)) {
|
|
39
|
+
_.forEach(obj, (val, key) => {
|
|
40
|
+
if (_.trim(val) != '' && _.isString(val)) {
|
|
41
|
+
const matches = val.match(regex);
|
|
42
|
+
|
|
43
|
+
if (!_.isEmpty(matches)) {
|
|
44
|
+
_.forEach(matches, (match) => {
|
|
45
|
+
try {
|
|
46
|
+
const tmpVal = mockExp(match, getInsideVariables(), option?.lang, option?.custom_functions || {});
|
|
47
|
+
|
|
48
|
+
if (tmpVal != match && !_.isUndefined(tmpVal)) {
|
|
49
|
+
_.set(cloneObj, [key], _.replace(val, match, tmpVal));
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
} catch (e) { }
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
iterationDataArr.push(cloneObj)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
31
63
|
const tempVars = { environment: _.get(option, 'env.environment', {}), globals: _.get(option, 'globals', {}), iterationDataArr };
|
|
32
64
|
|
|
33
65
|
['environment', 'globals', 'iterationDataArr'].forEach((type) => {
|
package/libs/utils.js
CHANGED
|
@@ -484,13 +484,14 @@ const encodeURIComponentUnique = (str) => {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
-
const jsfGenerate = (schema, mockRules = [], lang) => {
|
|
487
|
+
const jsfGenerate = (schema, mockRules = [], lang, customFunctions = {}) => {
|
|
488
488
|
jsf.option({
|
|
489
489
|
alwaysFakeOptionals: true,
|
|
490
490
|
useExamplesValue: true,
|
|
491
491
|
fillProperties: false,
|
|
492
492
|
useDefaultValue: true,
|
|
493
493
|
mockRules,
|
|
494
|
+
customFunctions,
|
|
494
495
|
lang: 'zh-cn',
|
|
495
496
|
});
|
|
496
497
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "runner-runtime",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.86",
|
|
4
4
|
"description": "runner-runtime.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"mime": "^3.0.0",
|
|
38
38
|
"minimatch": "^9.0.4",
|
|
39
39
|
"mockjs5-pro": "^1.0.6",
|
|
40
|
-
"json-schema-faker-pro": "^0.5.
|
|
41
|
-
"exp-mock": "^2.0.
|
|
40
|
+
"json-schema-faker-pro": "^0.5.32",
|
|
41
|
+
"exp-mock": "^2.0.18",
|
|
42
42
|
"msgpack5": "^6.0.2",
|
|
43
43
|
"net": "^1.0.2",
|
|
44
44
|
"postman-collection": "^5.0.2",
|