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

mocha-gherkin

v0.2.0

Published

mocha-gherkin is a Gherkin-style interface and reporter add-on for mocha.

Downloads

251

Readme

mocha-gherkin

NPM Version Build Status Coverage Status Dependency Status

mocha-gherkin is a Gherkin-style interface and reporter add-on for mocha. This add-on allows you to describe your features using Feature, Scenario, Given, When, Then, And, and But. You can use this interface together with mocha's BDD interface.

Usage in ECMAScript 6

Feature('Addition',
  'In order to avoid silly mistakes,',
  'As a math idiot',
  'I want to be told the sum of two numbers', () => {
    Scenario('Add two numbers', () => {
      let number1;
      let number2;
      let sum;

      Given('I have entered 50 into the calculator', () => {
        number1 = 50;
      });
      And('I have entered 70 into the calculator', () => {
        number2 = 70;
      });
      When('I press add', () => {
        sum = number1 + number2;
      });
      Then('the result should be 120 on the screen', () => {
        expect(sum).to.equal(120);
      });
    });
  });

Usage in ECMAScript 5

Feature('Addition',
  'In order to avoid silly mistakes,',
  'As a math idiot',
  'I want to be told the sum of two numbers', function () {
    Scenario('Add two numbers', function () {
      var number1;
      var number2;
      var sum;

      Given('I have entered 50 into the calculator', function () {
        number1 = 50;
      });
      And('I have entered 70 into the calculator', function () {
        number2 = 70;
      });
      When('I press add', function () {
        sum = number1 + number2;
      });
      Then('the result should be 120 on the screen', function () {
        expect(sum).to.equal(120);
      });
    });
  });

Installing

You should first have mocha installed:

$ npm install mocha

Then install mocha-gherkin, either globally or inside your project:

$ npm install mocha-gherkin

How to Use

Actually, mocha-gherkin consists of two different add-ons: interface add-on and reporter add-on. To use mocha-gherkin, you should first write your features using terms provided by the interface add-on. Then, run mocha with the options below:

$ mocha tests/addition.feature.js --ui mocha-gherkin --reporter mocha-gherkin/build/spec

Screenshot of mocha-gherkin

What's Going on?

Feature and Scenario wrap around mocha's describe, and Given, When, Then, And, and But do the same thing for mocha's it. describe, context, it, and other mocha's BDD lingos still work as usal, so you can mix in them with the Gherkin-style terms.

Reporter Support

mocha-gherkin has currently only one reporter add-on, which extends mocha's spec with support for the Gherkin-style interface. However, you can use other modules as usual since mocha-gherkin just wraps around mocha's BDD interface.