npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cucumber-cypress-decorators

v0.1.2

Published

Typescript Decorators for Cucumber with support for Cypress

Downloads

6

Readme

cucumber-cypress-decorators

Adds typescript decorator support for use with cypress-cucumber-preprocessor

Basic example

Assumes cypress-cucumber-preprocessor is installed and configured properly

Feature file

Feature: Simple maths
  To do maths
  As a developer
  I want to increment variables

  Scenario: easy maths
    Given a variable set to 1
    When I increment the variable by 1
    Then the variable should contain 2

  Scenario Outline: much more complex stuff
    Given a variable set to <var>
    When I increment the variable by <increment>
    Then the variable should contain <result>

    Examples:
      | var | increment | result |
      | 100 | 5         | 105    |
      | 99  | 1234      | 1333   |
      | 12  | 5         | 17     |

Typescript integration file

import { Feature, Given, Then, When } from 'cucumber-cypress-decorators'

@Feature('Simple maths')
export default class SimpleMath {
  variable: number = 0

  @Given('a variable set to {int}')
  setVariable(num) {
    this.variable = num
  }

  @When('I increment the variable by {int}')
  incrVariable(num) {
    this.variable = this.variable + num
  }

  @Then('the variable should contain {int}')
  assertValue(num) {
    expect(this.variable).to.equal(num)
  })
}

Notes

  • The step definitions using decorators are not executed until right before the test is executed.
  • The feature name on the class decorator must match the Cucumber feature name or the step definitions will not be executed. eg. @Feature('Simple maths') works but @Feature('Simple math') will result in errors about missing step definitions.
  • The class instance is recreated for each scenario so in this example variable always starts as 0 for each example.
  • The library supports both uppercase and lowercase step names to match your preferred style. eg. After, And, Before, But, Feature, Given, Then, When or after, and, before, but, feature, given, then, when
  • Multiple features per file hasn't been tested and probably won't work.

Inheritance example

The library supports step definition inheritance if the class extends another class already using step deinition decorators.

Feature file

Feature: Complex maths
  To do maths
  As a developer
  I want to increment variables

  Scenario Outline: much more complex stuff
    Given a variable set to <var>
    When I increment the variable by <increment>
    And multiply it by 2 # <------ new step
    Then the variable should contain <result>

    Examples:
      | var | increment | result |
      | 100 | 5         | 210    |
      | 99  | 1234      | 2666   |
      | 12  | 5         | 34     |

Typescript integration file

import { Feature, Given, Then, When } from 'cucumber-cypress-decorators'

import SimpleMath from '../simple-math'

@Feature('Complex maths')
export class ComplexMath extends SimpleMath {
  @When('I increment the variable by {int}')
  incrVariables(num) {
    console.log('I am the same but different than the parent')
    this.variable = this.variable + num
  }

  @And('multiply it by 2')
  multiplyBy2() {
    this.variable = this.variable * 2
  }
}

Notes

  • If you define a step that has already been defined by a parent class the parent step definition will be ignored when the step definintions are executed.

Vanilla step definition support

The library also supports vanilla step definitions using the same functions used for decorators to make life easy.

This example is functionally equivalent to the Simple maths example above

import { Feature, Given, Then, When } from 'cucumber-cypress-decorators'

let variable = 0

Given('a variable set to {int}', (num) => {
  variable = num
})

@Feature('Simple maths')
export default class SimpleMath {
  @When('I increment the variable by {int}')
  incrVariable(num) {
    variable = this.variable + num
  }
}

Then('the variable should contain {int}', (num) => {
  expect(variable).to.equal(num)
})

Notes

  • Vanilla step definitions are executed as soon as they are called like normal