cucumber-ai
Version:
Write automated tests using natural language
27 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StepAgent = void 0;
const step_loader_1 = require("../loaders/step-loader");
class StepAgent {
constructor(context) {
this.context = context;
}
async start() {
this.definedSteps = (0, step_loader_1.loadSteps)();
}
async stop() { }
async executeStep(stepText) {
const match = await this.findMatchedStep(stepText);
if (!match.step) {
throw new Error(`Step not found: ${stepText}`);
}
await this.context.getActionAgent().executeActions(match.step.actions, match.args);
}
async findMatchedStep(stepText) {
const stepTextList = this.definedSteps.map((s) => s.text);
const matchedStep = await this.context.getTextAgent().find(stepTextList, stepText);
return { step: this.definedSteps.find((s) => s.text === matchedStep.text), args: matchedStep.args };
}
}
exports.StepAgent = StepAgent;
//# sourceMappingURL=index.js.map