weir

Library for creating BDD-style test flows for JavaScript

weir

Library for building and running BDD flows.

  • Nested describe()
  • Sync or async it()
  • Sync or async before/beforeEach/after/afterEach
  • Select/omit it() execution by regular expression
  • Manage it() and hook contexts with property injection/omission
  • Supply your own assertion library

API modeled after Mocha.

  • conjure: Relies on weir for test composition. Injects the standard CasperJS testing API, and custom wrappers, into each it().
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.selectorExists('.remember-me');
        this.selectorMissing('.remember-me:checked');
      });
    });
  });
};
flow = weir.create();
flow
  .addRootDescribe('subject', function() {
    this.it('should do X', function() {
      // ... 
    });
  })
  .run();
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();
flow = weir.create();
flow
  .set('grep', /should run/)
  .addContextProp('foo', 'bar')
  .addContextProp('hello', 'world')
  .hideContextProp('it', 'hello')
  .addRootDescribe('subject', function() {
    this.describe(function() {
      this.describe(function() {
        this.beforeEach(function() {
          // this.foo = 'bar' 
          // this.hello = 'world'; 
        });
        this.it('should run', function() {
          // this.foo = 'bar' 
          // this.hello = undefined 
        });
        this.it('should not run', function() {
          // ... 
        });
      });
    });
  })
  .run();

Component

$ component install codeactual/weir

NPM

npm install weir

Weir/Describe

MIT

npm test