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

Latest commit

 

History

History
260 lines (158 loc) · 7.02 KB

Weir.md

File metadata and controls

260 lines (158 loc) · 7.02 KB

Library for creating BDD-style test flows for JavaScript

Source: lib/weir/index.js

exports.Weir()

Weir constructor.

Go: TOC | exports

exports.create()

Create a new Weir.

Return:

{object}

Go: TOC | exports

exports.extend(ext)

Extend Weir.prototype.

Parameters:

  • {object} ext

Return:

{object} Merge result.

Go: TOC | exports

Weir()

Weir constructor.

Usage:

var flow = require('weir').create();
flow
  .addRootDescribe('subject', function() {
    this.it('should do X', function() {
    // ...
    });
  })
  .addContextProp('someKey', someVal)
  .set('done', function() {
    console.log('Run finished.');
  })
  .run();

Configuration:

  • {function} done Callback fired after run finishes
  • {function} itWrap it() wrapper from which context can be shared
  • {function} describeWrap describe() wrapper from which context can be shared
  • {object} omitContextRegex Property name patterns
    • Ex. used to omit properties from propagating between it() handlers
    • Indexed by type: all, describe, hook, it, rootDescribe
    • Values are arrays of RegExp.
  • {array} path Names of ancestor describe levels to the currently executing it()
  • {regexp} grep Filter it() execution by current path + it() name
  • {regexp} grepv Omit it() execution by current path + it() name
  • {object} sharedContext Shared this updated after each hook/describe/it execution
  • {object} stats
    • {number} depth Current stack depth during test run

Properties:

  • {array} rootDescribe Top-level Describe objects
  • {object} batch Batch instance used to run collected test steps
  • {object} seedProps Merged into initial hook/describe/it context

Inherits:

  • emitter component

See:

Go: TOC

Weir.prototype.addContextProp(key, val)

Add a property to the initial hook/describe/it shared context.

Parameters:

  • {string} key
  • {mixed} val

Return:

{object} this

Go: TOC | Weir.prototype

Weir.prototype.addRootDescribe(name, cb)

Add a top-level describe().

Parameters:

  • {string} name
  • {function} cb

Return:

{object} this

Go: TOC | Weir.prototype

Weir.prototype.currentDepth()

Get the current stack depth.

Return:

{number}

  • 0 = every root describe()
  • Each deeper describe() is 1 more than its parent describe().
  • Each it() is 1 more than its parent describe().

Go: TOC | Weir.prototype

Weir.prototype.hideContextProp(type, regex)

Prevent a type of flow function from 'inheriting' specific context properties from enclosing/subsequently-executed flow functions.

Parameters:

  • {string} type 'it', 'hook'
  • {regexp} regex

Return:

{object} this

Go: TOC | Weir.prototype

Weir.prototype.run()

Run collected describe() steps.

See:

Go: TOC | Weir.prototype

Describe.prototype.it(name, cb)

Add an it() step.

Parameters:

  • {string} name
  • {function} cb Batch#push compatible

See:

Go: TOC | Describe.prototype

Describe.prototype.describe(name, cb)

Add a describe() step.

Parameters:

  • {string} name
  • {function} cb Batch#push compatible

See:

Go: TOC | Describe.prototype

Describe.prototype.before(cb)

Run a custom hook before the first it() in the current describe().

Parameters:

  • {function} cb
    • Async-mode is optional and auto-detected: function(done) { ... done(); }

Go: TOC | Describe.prototype

Describe.prototype.beforeEach(cb)

Run a custom hook before each it() in the current describe().

Parameters:

  • {function} cb
    • Async-mode is optional and auto-detected: function(done) { ... done(); }

Go: TOC | Describe.prototype

Describe.prototype.after(cb)

Run a custom hook after the last it() in the current describe().

Parameters:

  • {function} cb
    • Async-mode is optional and auto-detected: function(done) { ... done(); }

Go: TOC | Describe.prototype

Describe.prototype.afterEach(cb)

Run a custom hook after each it() in the current describe().

Parameters:

  • {function} cb
    • Async-mode is optional and auto-detected: function(done) { ... done(); }

Go: TOC | Describe.prototype

—generated by apidox