weir

Library for creating BDD-style test flows for JavaScript

npm install weir
4 downloads in the last week
16 downloads in the last month

weir

Library for creating BDD-style test flows for JavaScript.

  • Nested describe()
  • Optionally async it() and before/beforeEach/after/afterEach hooks
  • Filter it() execution by regular expression
  • Manage it() and hook contexts with property injection/omission
  • Supply your own runner CLI, assertion library, etc.

API modeled after Mocha.

Build Status

Goal

Ability to add BDD-style flow to new environments like CasperJS/PhantomJS, but integrate with preexisting assertion APIs, etc.

Use case: conjure, a CasperJS runner and library

conjure allows you to write modular tests in a BDD-style flow.

module.exports = function(conjure) {
  conjure.set('initUrl', '/login').set('initSel', '.login');

  conjure.test('login page', function() {
    this.describe('form', function() {
      this.it('should not auto-check "Remember Me"' , function() {
        this.conjure.selectorExists('.remember-me');
        this.conjure.selectorMissing('.remember-me:checked');
      });
    });
  });
};

Standard CasperJS APIs like casper and utils are injected into test method contexts using addContextProp().

Examples

Basic run

flow = weir.create();
flow
  .addRootDescribe('subject', function() {
    this.it('should do X', function() {
      // ...
    });
  })
  .run();

Async it() and beforeEach()

flow = weir.create();
flow
  .addRootDescribe('subject', function() {
    this.beforeEach(function(done) {
      this.fixture = 'foo';
      done();
    });
    this.it('should receive fixture prepared by hook', function(done) {
      // this.fixture still equals 'foo'
      done();
    });
  })
  .run();

More

Installation

Component

$ component install codeactual/weir

NPM

npm install weir

Documentation

License

MIT

Tests

npm test
npm loves you