Skip to content
This repository has been archived by the owner on Sep 9, 2019. It is now read-only.

Latest commit

 

History

History
109 lines (85 loc) · 2 KB

examples.md

File metadata and controls

109 lines (85 loc) · 2 KB

General

Nested describe() with it() filtering and custom context properties

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();

Events

describePush

A describe() is about to run its collected steps.

flow.on('describePush', function(name) {
  console.log('describe() started: %s', name);
});

describePop

A describe() finished its collected steps, including nested describe() if any.

flow.on('describePop', function(name) {
  console.log('describe() finished: %s', name);
});

itPush

An it() step is about to run.

flow.on('itPush', function(name) {
  console.log('it() started: %s', name);
});

itPop

An it() step finished.

flow.on('itPop', function(name) {
  console.log('it() finished: %s', name);
});

Context-injection wrappers

describeWrap

Set a describeWrap function if you need to customize the context of each function passed to describe().

flow.set('describeWrap', function (name, cb) {
  var secretSauce = {};
  // ...
  cb.call(secretSauce);
});

itWrap

Set an itWrap function if you need to customize the context of each function passed to it().

flow.set('itWrap', function(name, cb) {
  var secretSauce = {};
  // ...
  cb.call(secretSauce);
});

// OR

flow.set('itWrap', function(name, cb, done) {
  doSomethingAsync(function() {
    var secretSauce = {};
    // ...
    cb.call(secretSauce);
    done();
  }):
});