@nice-digital/wdio-cucumber-steps
Version:
Shared step definitions for Cucumber JS BDD tests in WebdriverIO
37 lines • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Then = exports.When = exports.Given = exports.customSteps = exports.CustomStepDefinition = void 0;
const cucumber_1 = require("@cucumber/cucumber");
class CustomStepDefinition {
constructor(stepType, pattern, code, options) {
this.stepType = stepType;
this.pattern = pattern;
this.code = code;
this.options = options;
this.docs = "";
this.examples = [];
}
withDocs(docs) {
this.docs = docs;
return this;
}
withExample(example) {
this.examples.push(example);
return this;
}
}
exports.CustomStepDefinition = CustomStepDefinition;
exports.customSteps = [];
const cucumberFunction = (stepType) => (...args) => {
const pattern = args[0], options = args.length === 3 ? args[1] : undefined, code = args.length === 2 ? args[1] : args[2];
// No need to actually call cucumber when we're getting the step defs to populate the readme
if (process.env.README !== "true")
// eslint-disable-next-line prefer-spread
cucumber_1.defineStep.apply(null, args);
const stepDef = new CustomStepDefinition(stepType, pattern, code, options);
return exports.customSteps.push(stepDef), stepDef;
};
exports.Given = cucumberFunction("given");
exports.When = cucumberFunction("when");
exports.Then = cucumberFunction("then");
//# sourceMappingURL=utils.js.map