@artilleryio/int-core 2.2.2 → 2.3.0-1b6220c

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.
Files changed (2) hide show
  1. package/lib/runner.js +17 -2
  2. package/package.json +3 -3
package/lib/runner.js CHANGED
@@ -471,8 +471,17 @@ function $randomNumber(min, max) {
471
471
  return _.random(min, max);
472
472
  }
473
473
 
474
- function $randomString(length) {
475
- return Math.random().toString(36).substr(2, length);
474
+ function $randomString(length = 10) {
475
+ let s = '';
476
+ const alphabet =
477
+ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
478
+ const alphabetLength = alphabet.length;
479
+
480
+ while (s.length < length) {
481
+ s += alphabet.charAt((Math.random() * alphabetLength) | 0);
482
+ }
483
+
484
+ return s;
476
485
  }
477
486
 
478
487
  function handleScriptHook(hook, script, hookEvents, contextVars = {}) {
@@ -493,6 +502,12 @@ function handleScriptHook(hook, script, hookEvents, contextVars = {}) {
493
502
 
494
503
  const name = script[hook].engine || 'http';
495
504
  const engine = engines.find((e) => e.__name === name);
505
+
506
+ if (typeof engine === 'undefined') {
507
+ throw new Error(
508
+ `Failed to run ${hook} hook: unknown engine "${name}". Did you forget to include it in "config.engines.${name}"?`
509
+ );
510
+ }
496
511
  const hookScenario = engine.createScenario(script[hook], ee);
497
512
  const hookContext = createContext(script, contextVars, {
498
513
  scenario: script[hook]
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@artilleryio/int-core",
3
- "version": "2.2.2",
3
+ "version": "2.3.0-1b6220c",
4
4
  "main": "./index.js",
5
5
  "license": "MPL-2.0",
6
6
  "dependencies": {
7
- "@artilleryio/int-commons": "2.0.4",
7
+ "@artilleryio/int-commons": "2.0.4-1b6220c",
8
8
  "@artilleryio/sketches-js": "^2.1.1",
9
9
  "agentkeepalive": "^4.1.0",
10
10
  "arrivals": "^2.1.2",
@@ -28,7 +28,6 @@
28
28
  "lodash": "^4.17.19",
29
29
  "ms": "^2.1.3",
30
30
  "protobufjs": "^7.2.4",
31
- "proxy": "^1.0.2",
32
31
  "socket.io-client": "^4.5.1",
33
32
  "socketio-wildcard": "^2.0.0",
34
33
  "tough-cookie": "^4.0.0",
@@ -48,6 +47,7 @@
48
47
  "@hapi/hapi": "^20.1.3",
49
48
  "express": "^4.16.3",
50
49
  "nock": "^11.8.2",
50
+ "proxy": "^2.1.1",
51
51
  "rewiremock": "^3.14.3",
52
52
  "sinon": "^4.5.0",
53
53
  "socket.io": "^4.7.1",