@artilleryio/int-core 2.0.7 → 2.0.9

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 CHANGED
@@ -20,7 +20,8 @@ async function updateGlobalObject(opts = {}) {
20
20
 
21
21
  global.artillery.util = global.artillery.util || {};
22
22
 
23
- global.artillery.util.template = require('@artilleryio/int-commons').engine_util.template;
23
+ global.artillery.util.template =
24
+ require('@artilleryio/int-commons').engine_util.template;
24
25
 
25
26
  global.artillery.plugins = global.artillery.plugins || [];
26
27
 
@@ -36,8 +37,7 @@ async function updateGlobalObject(opts = {}) {
36
37
  if (!global.artillery.hasOwnProperty('globalEvents')) {
37
38
  Object.defineProperty(global.artillery, 'globalEvents', {
38
39
  value: new EventEmitter()
39
- })
40
-
40
+ });
41
41
  }
42
42
 
43
43
  global.artillery.__SSMS = require('./lib/ssms').SSMS;
@@ -50,23 +50,30 @@ async function updateGlobalObject(opts = {}) {
50
50
  set(code) {
51
51
  global.artillery._exitCode = code;
52
52
  if (typeof global.artillery._workerThreadSend === 'function') {
53
- global.artillery._workerThreadSend({ event: 'setSuggestedExitCode', code: code });
53
+ global.artillery._workerThreadSend({
54
+ event: 'setSuggestedExitCode',
55
+ code: code
56
+ });
54
57
  }
55
58
  }
56
59
  });
57
60
  }
58
61
 
59
- global.artillery.logger = global.artillery.logger || function (opts) {
60
- return {
61
- log: (...args) => {
62
- global.artillery.globalEvents.emit('log', opts, ...args);
63
- }
62
+ global.artillery.logger =
63
+ global.artillery.logger ||
64
+ function (opts) {
65
+ return {
66
+ log: (...args) => {
67
+ global.artillery.globalEvents.emit('log', opts, ...args);
68
+ }
69
+ };
64
70
  };
65
- };
66
71
 
67
- global.artillery.log = global.artillery.log || function (...args) {
68
- global.artillery.globalEvents.emit('log', {}, ...args);
69
- };
72
+ global.artillery.log =
73
+ global.artillery.log ||
74
+ function (...args) {
75
+ global.artillery.globalEvents.emit('log', {}, ...args);
76
+ };
70
77
 
71
78
  if (opts.version) {
72
79
  global.artillery.version = opts.version;
@@ -85,9 +85,9 @@ function HttpEngine(script) {
85
85
  this.config.http = {};
86
86
  }
87
87
 
88
- if(typeof this.config.http.cookieJarOptions === 'undefined') {
88
+ if (typeof this.config.http.cookieJarOptions === 'undefined') {
89
89
  this.config.http.cookieJarOptions = {};
90
- };
90
+ }
91
91
 
92
92
  // If config.http.pool is set, create & reuse agents for all requests (with
93
93
  // max sockets set). That's what we're done here.
@@ -507,7 +507,7 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
507
507
  debugResponse(JSON.stringify(body, null, 2));
508
508
 
509
509
  // capture/match/response hooks run only for last request in a task
510
- if(!isLast) {
510
+ if (!isLast) {
511
511
  return done(null, context);
512
512
  }
513
513
 
@@ -612,10 +612,7 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
612
612
 
613
613
  if (haveFailedMatches || haveFailedCaptures) {
614
614
  // FIXME: This means only one error in the report even if multiple captures failed for the same request.
615
- return done(
616
- new Error('Failed capture or match'),
617
- context
618
- );
615
+ return done(new Error('Failed capture or match'), context);
619
616
  }
620
617
  return done(null, context);
621
618
  }
@@ -678,7 +675,6 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
678
675
  callback
679
676
  );
680
677
  });
681
-
682
678
  })
683
679
  .on('downloadProgress', (progress) => {
684
680
  totalDownloaded = progress.total;
@@ -737,7 +733,9 @@ HttpEngine.prototype._handleResponse = function (
737
733
  try {
738
734
  context._jar.setCookieSync(cookieString, url);
739
735
  } catch (err) {
740
- debug(`Could not parse cookieString "${cookieString}" from response header, skipping it`);
736
+ debug(
737
+ `Could not parse cookieString "${cookieString}" from response header, skipping it`
738
+ );
741
739
  debug(err);
742
740
  ee.emit('error', 'cookie_parse_error_invalid_cookie');
743
741
  }
@@ -775,8 +773,8 @@ HttpEngine.prototype._handleResponse = function (
775
773
 
776
774
  if (responseProcessor) {
777
775
  responseProcessor(isLastRequest, res, body, (processResponseErr) => {
778
- // capture/match returned an error object, or a hook function returned
779
- // with an error
776
+ // capture/match returned an error object, or a hook function returned
777
+ // with an error
780
778
  if (processResponseErr) {
781
779
  return callback(processResponseErr, context);
782
780
  }
@@ -798,15 +796,23 @@ function lastRequest(res, requestParams) {
798
796
  // - 3xx response and not following redirects
799
797
  // - not a 3xx response
800
798
 
801
- return ((res.statusCode >= 300 && res.statusCode < 400 && !requestParams.followRedirect) ||
802
- (res.statusCode < 300 || res.statusCode >= 400))
799
+ return (
800
+ (res.statusCode >= 300 &&
801
+ res.statusCode < 400 &&
802
+ !requestParams.followRedirect) ||
803
+ res.statusCode < 300 ||
804
+ res.statusCode >= 400
805
+ );
803
806
  }
804
807
 
805
808
  HttpEngine.prototype.setInitialContext = function (initialContext) {
806
809
  initialContext._successCount = 0;
807
810
 
808
811
  initialContext._defaultStrictCapture = this.config.defaults.strictCapture;
809
- initialContext._jar = new tough.CookieJar(null, this.config.http.cookieJarOptions);
812
+ initialContext._jar = new tough.CookieJar(
813
+ null,
814
+ this.config.http.cookieJarOptions
815
+ );
810
816
 
811
817
  initialContext._enableCookieJar = false;
812
818
  // If a default cookie is set, we will use the jar straightaway:
package/lib/readers.js CHANGED
@@ -11,9 +11,14 @@ module.exports = createReader;
11
11
  function createReader(order, spec) {
12
12
  if (order === 'sequence') {
13
13
  return createSequencedReader();
14
- } else if (typeof order === 'undefined' && (typeof spec?.name !== 'undefined') && spec?.loadAll === true) {
14
+ } else if (
15
+ typeof order === 'undefined' &&
16
+ typeof spec?.name !== 'undefined' &&
17
+ spec?.loadAll === true
18
+ ) {
15
19
  return createEverythingReader(spec);
16
- } else { // random
20
+ } else {
21
+ // random
17
22
  return createRandomReader();
18
23
  }
19
24
  }
@@ -42,10 +47,10 @@ function createEverythingReader(spec) {
42
47
  if (spec.fields?.length > 0) {
43
48
  for (const row of data) {
44
49
  let o = {};
45
- for(let i = 0; i < spec.fields.length; i++) {
46
- const fieldName = spec.fields[i];
47
- o[fieldName] = row[i];
48
- }
50
+ for (let i = 0; i < spec.fields.length; i++) {
51
+ const fieldName = spec.fields[i];
52
+ o[fieldName] = row[i];
53
+ }
49
54
  parsedData.push(o);
50
55
  }
51
56
  } else {
package/lib/runner.js CHANGED
@@ -103,7 +103,10 @@ function prepareScript(script, payload) {
103
103
  runnableScript.config.payload = [
104
104
  {
105
105
  fields: runnableScript.config.payload.fields,
106
- reader: createReader(runnableScript.config.payload.order, runnableScript.config.payload),
106
+ reader: createReader(
107
+ runnableScript.config.payload.order,
108
+ runnableScript.config.payload
109
+ ),
107
110
  data: payload
108
111
  }
109
112
  ];
@@ -387,7 +390,7 @@ function createContext(script, contextVars) {
387
390
  target: script.config.target,
388
391
  $environment: script._environment,
389
392
  $processEnvironment: process.env, // TODO: deprecate
390
- $env: process.env,
393
+ $env: process.env
391
394
  },
392
395
  contextVars || {}
393
396
  ),
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@artilleryio/int-core",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "main": "./index.js",
5
5
  "dependencies": {
6
6
  "@artilleryio/int-commons": "latest",
7
- "@artilleryio/sketches-js": "^1.0.4",
7
+ "@artilleryio/sketches-js": "^2.1.1",
8
8
  "agentkeepalive": "^4.1.0",
9
9
  "arrivals": "^2.1.2",
10
10
  "async": "^2.6.4",
@@ -26,7 +26,6 @@
26
26
  "https-proxy-agent": "^5.0.0",
27
27
  "lodash": "^4.17.19",
28
28
  "proxy": "^1.0.2",
29
- "socket.io": "^3.1.2",
30
29
  "socket.io-client": "^4.5.1",
31
30
  "socketio-wildcard": "^2.0.0",
32
31
  "tough-cookie": "^4.0.0",
@@ -46,6 +45,7 @@
46
45
  "nock": "^11.8.2",
47
46
  "rewiremock": "^3.14.3",
48
47
  "sinon": "^4.5.0",
48
+ "socket.io": "^4.7.1",
49
49
  "tap": "15.2.3"
50
50
  }
51
51
  }