@testsmith/perfornium 0.6.1 → 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.
- package/dist/core/step-executor.js +23 -5
- package/package.json +1 -1
|
@@ -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(`
|
|
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
|
-
|
|
687
|
-
|
|
688
|
-
|
|
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(
|
|
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
|
}
|