@testsmith/perfornium 0.6.0 → 0.6.2

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');
@@ -551,6 +553,7 @@ class StepExecutor {
551
553
  });
552
554
  const resultPromise = Promise.resolve(fn(execParams));
553
555
  const result = await Promise.race([resultPromise, timeoutPromise]);
556
+ logger_1.logger.debug(`Script ${funcName} returned: ${JSON.stringify(result)}`);
554
557
  // Store return value if specified
555
558
  if (returns && result !== undefined) {
556
559
  context.extracted_data[returns] = result;
@@ -609,7 +612,8 @@ class StepExecutor {
609
612
  ...context.extracted_data
610
613
  };
611
614
  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)}`);
615
+ logger_1.logger.debug(`Extracted data keys: ${Object.keys(context.extracted_data || {}).join(', ') || '(none)'}`);
616
+ logger_1.logger.debug(`Context data keys at top level: ${Object.keys(contextData).join(', ')}`);
613
617
  const stepStr = JSON.stringify(step);
614
618
  logger_1.logger.debug(`Original step JSON: ${stepStr}`);
615
619
  const processed = this.templateProcessor.process(stepStr, contextData);
@@ -683,26 +687,40 @@ class StepExecutor {
683
687
  for (const extractor of extractors) {
684
688
  try {
685
689
  let value;
686
- switch (extractor.type) {
687
- case 'json_path':
688
- value = this.getJsonPath(result.data, extractor.expression);
690
+ // Normalize type: accept both "jsonpath" and "json_path"
691
+ const extractType = (extractor.type || 'jsonpath').toLowerCase().replace('_', '');
692
+ // Normalize expression: accept both "path" and "expression"
693
+ const expression = extractor.expression || extractor.path;
694
+ switch (extractType) {
695
+ case 'jsonpath':
696
+ value = this.getJsonPath(result.data, expression);
689
697
  break;
690
698
  case 'regex':
691
- const match = String(result.data).match(new RegExp(extractor.expression));
699
+ const match = String(result.data).match(new RegExp(expression));
692
700
  value = match ? (match[1] || match[0]) : null;
693
701
  break;
702
+ case 'header':
703
+ value = result.headers?.[expression.toLowerCase()];
704
+ break;
694
705
  case 'custom':
695
706
  value = await this.extractCustom(extractor.script, result, context);
696
707
  break;
708
+ default:
709
+ // Default to jsonpath if type not recognized but path/expression provided
710
+ if (expression) {
711
+ value = this.getJsonPath(result.data, expression);
712
+ }
697
713
  }
698
714
  if (value !== null && value !== undefined) {
699
715
  context.extracted_data[extractor.name] = value;
716
+ logger_1.logger.debug(`Extracted ${extractor.name} = ${JSON.stringify(value)}`);
700
717
  }
701
718
  else if (extractor.default !== undefined) {
702
719
  context.extracted_data[extractor.name] = extractor.default;
703
720
  }
704
721
  }
705
722
  catch (error) {
723
+ logger_1.logger.debug(`Extraction failed for ${extractor.name}: ${error}`);
706
724
  if (extractor.default !== undefined) {
707
725
  context.extracted_data[extractor.name] = extractor.default;
708
726
  }
@@ -1097,18 +1097,24 @@ class DashboardServer {
1097
1097
  container.innerHTML = '<div class="empty-state"><h3>No tests found</h3><p>Add test files to your tests/ folder</p></div>';
1098
1098
  return;
1099
1099
  }
1100
- container.innerHTML = testFiles.map(t => \`
1100
+ container.innerHTML = testFiles.map((t, idx) => \`
1101
1101
  <div class="test-item">
1102
1102
  <div class="test-info">
1103
1103
  <div class="test-name">\${t.name}</div>
1104
1104
  <div class="test-path">\${t.relativePath}</div>
1105
1105
  </div>
1106
1106
  <span class="test-type \${t.type}">\${t.type}</span>
1107
- <button class="btn btn-primary btn-sm" style="margin-left: 12px;" onclick="runTest('\${t.path}')" \${runningTestId ? 'disabled' : ''}>Run</button>
1107
+ <button class="btn btn-primary btn-sm" style="margin-left: 12px;" onclick="runTestByIndex(\${idx})" \${runningTestId ? 'disabled' : ''}>Run</button>
1108
1108
  </div>
1109
1109
  \`).join('');
1110
1110
  }
1111
1111
 
1112
+ function runTestByIndex(idx) {
1113
+ if (idx >= 0 && idx < testFiles.length) {
1114
+ runTest(testFiles[idx].path);
1115
+ }
1116
+ }
1117
+
1112
1118
  async function runTest(testPath) {
1113
1119
  if (runningTestId) return;
1114
1120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testsmith/perfornium",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Flexible performance testing framework for REST, SOAP, and web applications",
5
5
  "author": "TestSmith",
6
6
  "license": "MIT",