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

intern-yadda-loader

v0.2.0

Published

Yadda loader for Intern

Downloads

8

Readme

intern-yadda-loader

Yadda loader for Intern

Yadda is a plain-language BDD system for Javascript. Intern is a flexible Javascript test runner. This package loads Yadda features/scenarios/steps as Intern suites/tests.

Features

  • Context tracking across scenario steps (unique per-scenario) using this.ctx.
  • Single, global step library similar to Cucumber and moonraker.
  • Promise-based step definitions (or use the Intern this.async() api).
  • AMD syntax for better Intern integration.

Installation

See the Intern User Guide for information on setting up an intern project. Then install yadda and intern-yadda-loader:

$ npm install yadda intern-yadda-loader --save-dev

NOTE: Yadda is a peer dependency of intern-yadda-loader.

Configuration

// `test/conf.js`
define({
  environments: [{browserName: 'phantomjs'}],
  loaderOptions: {
    packages: [
      // Load `intern-yadda-loader` as `yadda`
      { name: 'yadda', location: './node_modules/intern-yadda-loader' },
      // Load package containing step definitions
      { name: 'steps', location: './test/steps' }
    ]
  },
  functionalSuites: [
    // Specify features to load
    'yadda!test/features/bottles.feature',
    'yadda!test/features/google.feature'
    // Also accepts directories, e.g. `yadda!test/features`
  ],
  // Yadda configuration
  yadda: {
    // An array or string specifying step definition packages to load
    steps: [
      'steps/bottles-library',
      'steps/google-library'
    ],
    // The language to use when parsing the features (default: `English`)
    lang: 'English'
  }
});

Examples

# `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
  And another falls
  Then there are 98 green bottles standing on the wall
// `test/steps/bottles-library.js`
define(function (require) {
  var expect = require('intern/chai!expect');

  return function (library) {
    library
      .given("$NUM green bottles are standing on the wall", function (number) {
        // The context is reused only within the current scenario.
        expect(this.ctx.bottles).to.be.undefined;
        this.ctx.bottles = parseInt(number);
      })
      .when("$NUM green bottle accidentally falls", function (number, next) {
        // Async using `next` callback.
        var ctx = this.ctx;
        setTimeout(function () {
          ctx.bottles--;
          next();
        }, 200);
      })
      .define("And another falls", function () {
        // Async using Intern `this.async()` convention.
        var ctx = this.ctx;
        var deferred = this.async();
        setTimeout(function () {
          ctx.bottles--;
          deferred.resolve();
        }, 200);
      })
      .then("there are $NUM green bottles standing on the wall", function (number) {
        expect(this.ctx.bottles).to.equal(parseInt(number));
      });
  };
});
# `test/features/google.feature`

Feature: Multilingual Google Search

Scenario: Searching Google For The First Time

  When I open Google's fr search page
  then the title is Google
  and the search form exists

  When I search for foo
  then the title is foo - Recherche Google
  and the search for foo was made
  and 10 or more results were returned

Scenario: Searching Google Again

  When I open Google's ie search page
  then the title is Google
  and the search form exists

  When I search for bar
  then the title is bar - Google Search
  and the search for bar was made
  and 10 or more results were returned  
// `test/steps/google-library.js`
define(function (require) {
  var expect = require('intern/chai!expect');

  return function (library, dictionary) {
    // Access to dictionary for custom definitions.
    dictionary
      .define('LOCALE', /(fr|es|ie)/)
      .define('NUM', /(\d+)/);

    library
      .when("I open Google's $LOCALE search page", function(locale) {
        return this.remote.get("http://www.google." + locale + "/");
      })
      .then("the title is $TITLE", function(title) {
        return this.remote
          .sleep(500)
          .getPageTitle()
          .then(function (pageTitle) {
            expect(pageTitle).to.equal(title);
          });
      })
      .then("the $ACTION form exists", function(action) {
        return this.remote
          .findByCssSelector('form[action="/' + action + '"]');
      })
      .when("I search for $TERM", function(term) {
        return this.remote
          .findByName('q')
          .click()
          .type(term + '\n');
      })
      .then("the search for $TERM was made", function(term) {
        var regex = new RegExp('q=' + term);
        return this.remote
          .sleep(500)
          .getCurrentUrl()
          .then(function (url) {
            expect(url).to.match(new RegExp('q=' + term));
          });
      })
      .then("$NUM or more results were returned", function(number) {
        return this.remote
          .findAllByCssSelector('h3.r')
          .then(function (elements) {
            expect(elements).to.have.length.of.at.least(parseInt(number));
          });
      });
  };
});

TODO

  • Docs
  • Tests