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

yadda

v2.2.0

Published

A true BDD framework for JavaScript

Downloads

2,973

Readme

Yadda

Gitter NPM version NPM downloads Node.js CI Code Climate Test Coverage Code Style

Jasmine, Mocha and Vows can fall out of date and are a form of duplication. Yadda brings true BDD to JavaScript frameworks such as Jasmine, Mocha, QUnit, Nodeunit, WebdriverIO and CasperJS. By true BDD we mean that the ordinary language (e.g. English) steps are mapped to code, as opposed to simply decorating it. This is important because just like comments, the decorative steps such as those used by

Yadda's BDD implementation is like Cucumber's in that it maps the ordinary language steps to code. Not only are the steps less likely to go stale, but they also provide a valuable abstraction layer and encourage re-use. You could of course just use CucumberJS, but we find Yadda less invasive and prefer it's flexible syntax to Gherkin's. Yadda's conflict resolution is smarter too.

Latest Version

The current version of Yadda is 2.2.0

Documentation

Please refer to the the Yadda User Guide.

tl;dr

Step 1 - Decide upon a directory structure, e.g.

.
├── bottles-test.js
├── lib
│    └── wall.js
└── test
    ├── features
    │   └── bottles.feature
    └── steps
        └── bottles-library.js

Step 2 - Write your first scenario

./test/features/bottles.feature

Feature: 100 Green Bottles

Scenario: Should fall from the wall

   Given 100 green bottles are standing on the wall
   When 1 green bottle accidentally falls
   Then there are 99 green bottles standing on the wall

Step 3 - Implement the step library

./test/steps/bottles-library.js

var assert = require('assert');
var English = require('yadda').localisation.English;
var Wall = require('../../lib/wall'); // The library that you wish to test

module.exports = (function () {
  return English.library()
    .given('$NUM green bottles are standing on the wall', function (number, next) {
      wall = new Wall(number);
      next();
    })
    .when('$NUM green bottle accidentally falls', function (number, next) {
      wall.fall(number);
      next();
    })
    .then('there are $NUM green bottles standing on the wall', function (number, next) {
      assert.equal(number, wall.bottles);
      next();
    });
})();

(If your test runner & code are synchronous you can omit the calls to 'next')

Step 4 - Integrate Yadda with your testing framework (e.g. Mocha)

./bottles-test.js

var Yadda = require('yadda');
Yadda.plugins.mocha.StepLevelPlugin.init();

new Yadda.FeatureFileSearch('./test/features').each(function (file) {
  featureFile(file, function (feature) {
    var library = require('./test/steps/bottles-library');
    var yadda = Yadda.createInstance(library);

    scenarios(feature.scenarios, function (scenario) {
      steps(scenario.steps, function (step, done) {
        yadda.run(step, done);
      });
    });
  });
});

Step 5 - Write your code

./lib/wall.js

module.exports = function (bottles) {
  this.bottles = bottles;
  this.fall = function (n) {
    this.bottles -= n;
  };
};

Step 6 - Run your tests

  mocha --reporter spec bottles-test.js

  100 Green Bottles
    Should fall from the wall
      ✓ Given 100 green bottles are standing on the wall
      ✓ When 1 green bottle accidentally falls
      ✓ Then there are 99 green bottles standing on the wall