artillery-plugin-apdex 1.23.0 → 1.24.0-a33c503

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.
@@ -2,7 +2,9 @@
2
2
  * License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
 
5
- const _debug = require('debug')('plugin:apdex');
5
+ import createDebug from 'debug';
6
+
7
+ const _debug = createDebug('plugin:apdex');
6
8
 
7
9
  const METRICS = {
8
10
  satisfied: 'apdex.satisfied',
@@ -11,6 +13,9 @@ const METRICS = {
11
13
  };
12
14
 
13
15
  class ApdexPlugin {
16
+ // Untyped JS class - properties assigned dynamically
17
+ [key: string]: any;
18
+
14
19
  constructor(script, _events) {
15
20
  this.script = script;
16
21
 
@@ -27,6 +32,11 @@ class ApdexPlugin {
27
32
  if (!script.config.processor) {
28
33
  script.config.processor = {};
29
34
  }
35
+ // In the main thread config.processor may still be an unresolved
36
+ // path (a string). Attaching functions to it was a silent no-op
37
+ // under sloppy mode; ES modules are strict, so guard explicitly.
38
+ // Workers load the processor into an object before plugins run.
39
+ const canAttach = typeof script.config.processor === 'object';
30
40
 
31
41
  script.scenarios.forEach((scenario) => {
32
42
  scenario.afterResponse = [].concat(scenario.afterResponse || []);
@@ -50,7 +60,9 @@ class ApdexPlugin {
50
60
  return done();
51
61
  }
52
62
 
53
- script.config.processor.apdexAfterResponse = apdexAfterResponse;
63
+ if (canAttach) {
64
+ script.config.processor.apdexAfterResponse = apdexAfterResponse;
65
+ }
54
66
 
55
67
  return;
56
68
  }
@@ -97,6 +109,4 @@ class ApdexPlugin {
97
109
  }
98
110
  }
99
111
 
100
- module.exports = {
101
- Plugin: ApdexPlugin
102
- };
112
+ export { ApdexPlugin as Plugin };
package/package.json CHANGED
@@ -1,23 +1,14 @@
1
1
  {
2
2
  "name": "artillery-plugin-apdex",
3
- "version": "1.23.0",
3
+ "version": "1.24.0-a33c503",
4
4
  "description": "Calculate and report Apdex scores",
5
- "main": "index.js",
5
+ "main": "index.ts",
6
6
  "scripts": {
7
- "test": "tap ./test/*.spec.js --timeout 300"
8
- },
9
- "tap": {
10
- "disable-coverage": true,
11
- "allow-empty-coverage": true,
12
- "color": true,
13
- "test-env": [
14
- "ARTILLERY_TELEMETRY_DEFAULTS={\"source\":\"test-suite\"}"
15
- ]
7
+ "test": "node --test --test-timeout=300000 --require ./test/setup-env.cjs \"test/*.spec.js\""
16
8
  },
17
9
  "keywords": [],
18
10
  "author": "",
19
11
  "license": "MPL-2.0",
20
- "devDependencies": {
21
- "tap": "^19.2.5"
22
- }
12
+ "devDependencies": {},
13
+ "type": "module"
23
14
  }