cucumber-enhancement

3.0.0 • Public • Published

cucumber-enhancement

Enhances cucumber.js to make it easier to interact between steps.

Simple usage

  • Create a file features/step_definitions/world-enhance.js as follows
const {setWorldConstructor} = require('cucumber');

setWorldConstructor(require('cucumber-enhancement'));

This modifies the World object to do the following:

  • Write attributes for later retrieval:
Given(/^I am on the "([^/"]*)\/([^"]*)" repository on GitHub$/, function (owner, repo) {
    // This saves owner and repo for use in other steps
    this.setAttributes({
        owner,
        repo
    });
});
  • Read attributes from previous steps:
Then(/^I should see "([^"]*)" as one of the branches$/, function (branch) {
    const data = this.getAttributes({
        branches: this.joi.array()
    });
 
    // data.branches contains data saved from another step
    expect(data.branches).to.contain(branch);
});
  • Exposes joi interface for quick access during step definition (see above).

Dependencies (2)

Dev Dependencies (6)

Package Sidebar

Install

npm i cucumber-enhancement

Weekly Downloads

1

Version

3.0.0

License

MIT

Last publish

Collaborators

  • stjohnjohnson