@testsmith/perfornium 0.6.1 → 0.6.3

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.
@@ -187,6 +187,7 @@ class StepExecutor {
187
187
  }
188
188
  let result;
189
189
  const stepType = step.type || 'rest';
190
+ logger_1.logger.debug(`Step type detected: "${stepType}" for step: ${step.name}`);
190
191
  switch (stepType) {
191
192
  case 'rest':
192
193
  result = await this.executeRESTStep(processedStep, context);
@@ -496,6 +497,7 @@ class StepExecutor {
496
497
  }
497
498
  }
498
499
  async executeScriptStep(step, context) {
500
+ logger_1.logger.info(`📜 Executing script step: file=${step.file}, function=${step.function}`);
499
501
  const { file, function: funcName, params, returns, timeout = 30000 } = step;
500
502
  const path = require('path');
501
503
  const fs = require('fs');
@@ -518,7 +520,10 @@ class StepExecutor {
518
520
  const Module = require('module');
519
521
  const tempModule = new Module(filePath);
520
522
  tempModule.filename = filePath;
521
- tempModule.paths = Module._nodeModulePaths(path.dirname(filePath));
523
+ // Include both script dir and cwd node_modules for dependency resolution
524
+ const scriptPaths = Module._nodeModulePaths(path.dirname(filePath));
525
+ const cwdPaths = Module._nodeModulePaths(process.cwd());
526
+ tempModule.paths = [...new Set([...scriptPaths, ...cwdPaths])];
522
527
  tempModule._compile(result.code, filePath);
523
528
  module = tempModule.exports;
524
529
  }
@@ -551,6 +556,7 @@ class StepExecutor {
551
556
  });
552
557
  const resultPromise = Promise.resolve(fn(execParams));
553
558
  const result = await Promise.race([resultPromise, timeoutPromise]);
559
+ logger_1.logger.debug(`Script ${funcName} returned: ${JSON.stringify(result)}`);
554
560
  // Store return value if specified
555
561
  if (returns && result !== undefined) {
556
562
  context.extracted_data[returns] = result;
@@ -609,7 +615,8 @@ class StepExecutor {
609
615
  ...context.extracted_data
610
616
  };
611
617
  logger_1.logger.debug(`StepExecutor processing template for VU${context.vu_id} Iter${context.iteration}`);
612
- logger_1.logger.debug(`Context data: ${JSON.stringify(contextData)}`);
618
+ logger_1.logger.debug(`Extracted data keys: ${Object.keys(context.extracted_data || {}).join(', ') || '(none)'}`);
619
+ logger_1.logger.debug(`Context data keys at top level: ${Object.keys(contextData).join(', ')}`);
613
620
  const stepStr = JSON.stringify(step);
614
621
  logger_1.logger.debug(`Original step JSON: ${stepStr}`);
615
622
  const processed = this.templateProcessor.process(stepStr, contextData);
@@ -683,26 +690,40 @@ class StepExecutor {
683
690
  for (const extractor of extractors) {
684
691
  try {
685
692
  let value;
686
- switch (extractor.type) {
687
- case 'json_path':
688
- value = this.getJsonPath(result.data, extractor.expression);
693
+ // Normalize type: accept both "jsonpath" and "json_path"
694
+ const extractType = (extractor.type || 'jsonpath').toLowerCase().replace('_', '');
695
+ // Normalize expression: accept both "path" and "expression"
696
+ const expression = extractor.expression || extractor.path;
697
+ switch (extractType) {
698
+ case 'jsonpath':
699
+ value = this.getJsonPath(result.data, expression);
689
700
  break;
690
701
  case 'regex':
691
- const match = String(result.data).match(new RegExp(extractor.expression));
702
+ const match = String(result.data).match(new RegExp(expression));
692
703
  value = match ? (match[1] || match[0]) : null;
693
704
  break;
705
+ case 'header':
706
+ value = result.headers?.[expression.toLowerCase()];
707
+ break;
694
708
  case 'custom':
695
709
  value = await this.extractCustom(extractor.script, result, context);
696
710
  break;
711
+ default:
712
+ // Default to jsonpath if type not recognized but path/expression provided
713
+ if (expression) {
714
+ value = this.getJsonPath(result.data, expression);
715
+ }
697
716
  }
698
717
  if (value !== null && value !== undefined) {
699
718
  context.extracted_data[extractor.name] = value;
719
+ logger_1.logger.debug(`Extracted ${extractor.name} = ${JSON.stringify(value)}`);
700
720
  }
701
721
  else if (extractor.default !== undefined) {
702
722
  context.extracted_data[extractor.name] = extractor.default;
703
723
  }
704
724
  }
705
725
  catch (error) {
726
+ logger_1.logger.debug(`Extraction failed for ${extractor.name}: ${error}`);
706
727
  if (extractor.default !== undefined) {
707
728
  context.extracted_data[extractor.name] = extractor.default;
708
729
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testsmith/perfornium",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Flexible performance testing framework for REST, SOAP, and web applications",
5
5
  "author": "TestSmith",
6
6
  "license": "MIT",