Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 1.31 KB

no-arrow-functions.md

File metadata and controls

56 lines (37 loc) · 1.31 KB

Disallow arrow functions on cucumber steps (no-arrow-functions)

When passing World and other objects via this you can run into issue with using arrow functions. This rule catches any use of arrow functions to prevent errors caused by these objects being undefined on the this instance inside the step definition.

Rule Details

This rule aims to catch any use of arrow functions when creating step definitions.

The following patterns are considered warnings:

Given(/some step/, () => {
  this.currentEnvironment.username = 'Dr. Acula';
});

Given(/some step/, (done) => {
  this.currentEnvironment.username = 'Dr. Acula';
});

Given(/some step/, (next) => {
  this.currentEnvironment.username = 'Dr. Acula';
});

Given(/some step/, (callback) => {
  this.currentEnvironment.username = 'Dr. Acula';
});

The following patterns are not warnings:

Given(/some step/, function () {
   this.currentEnvironment.username = 'Dr. Acula'; 
});

Given(/some step/, function (done) {
   this.currentEnvironment.username = 'Dr. Acula'; 
});

Given(/some step/, function (next) {
   this.currentEnvironment.username = 'Dr. Acula'; 
});

Given(/some step/, function (callback) {
   this.currentEnvironment.username = 'Dr. Acula'; 
});

When Not To Use It

When you're not using this to pass in objects between steps.