Module: lib/interfaces/common

Functions common to more than one interface

(require("lib/interfaces/common"))()

TDD-style interface:

exports.Array = {
  '#indexOf()': {
    'should return -1 when the value is not present': function(){

    },

    'should return the correct index when the value is present': function(){

    }
  }
};
Source:

(require("lib/interfaces/common"))()

QUnit-style interface:

suite('Array');

test('#length', function(){
  var arr = [1,2,3];
  ok(arr.length == 3);
});

test('#indexOf()', function(){
  var arr = [1,2,3];
  ok(arr.indexOf(1) == 0);
  ok(arr.indexOf(2) == 1);
  ok(arr.indexOf(3) == 2);
});

suite('String');

test('#length', function(){
  ok('foo'.length == 3);
});
Source:

(require("lib/interfaces/common"))()

TDD-style interface:

 suite('Array', function(){
   suite('#indexOf()', function(){
     suiteSetup(function(){

     });

     test('should return -1 when not present', function(){

     });

     test('should return the index when present', function(){

     });

     suiteTeardown(function(){

     });
   });
 });
Source:

module:lib/interfaces/common

Expose Mocha.

Source:

(require("lib/interfaces/common"))(val, options) → {String|Number}

Parse or format the given val.

Options:

  • long verbose formatting [false]
Parameters:
Name Type Description
val String | Number
options Object
Source:
Returns:
Type
String | Number

module:lib/interfaces/common

Expose Pending.

Source:

module:lib/interfaces/common

Expose Base.

Source:

module:lib/interfaces/common

Expose Dot.

Source:

module:lib/interfaces/common

Expose HTMLCov.

Source:

module:lib/interfaces/common

Expose HTML.

Source:

module:lib/interfaces/common

Expose JSONCov.

Source:

module:lib/interfaces/common

Expose List.

Source:

module:lib/interfaces/common

Expose JSON.

Source:

module:lib/interfaces/common

Expose JUnit.

Source:

module:lib/interfaces/common

Expose Landing.

Source:

module:lib/interfaces/common

Expose List.

Source:

module:lib/interfaces/common

Expose Markdown.

Source:

module:lib/interfaces/common

Expose Min.

Source:

module:lib/interfaces/common

Expose Dot.

Source:

module:lib/interfaces/common

Expose Progress.

Source:

module:lib/interfaces/common

Expose Spec.

Source:

module:lib/interfaces/common

Expose TAP.

Source:

module:lib/interfaces/common

Expose Text.

Source:

module:lib/interfaces/common

Expose XUnit.

Source:

module:lib/interfaces/common

Expose Runnable.

Source:

module:lib/interfaces/common

Expose Runner.

Source:

module:lib/interfaces/common

Expose Suite.

Source:

module:lib/interfaces/common

Expose Test.

Source:

module:lib/interfaces/common

Expose Doc.

Source:
Source:

Members

module:lib/interfaces/common

Expose Mocha.

Source:

module:lib/interfaces/common

Expose Base.

Source:

module:lib/interfaces/common

Expose Dot.

Source:

module:lib/interfaces/common

Expose HTMLCov.

Source:

module:lib/interfaces/common

Expose HTML.

Source:

module:lib/interfaces/common

Expose JSONCov.

Source:

module:lib/interfaces/common

Expose List.

Source:

module:lib/interfaces/common

Expose JSON.

Source:

module:lib/interfaces/common

Expose JUnit.

Source:

module:lib/interfaces/common

Expose Landing.

Source:

module:lib/interfaces/common

Expose List.

Source:

module:lib/interfaces/common

Expose Markdown.

Source:

module:lib/interfaces/common

Expose Min.

Source:

module:lib/interfaces/common

Expose Dot.

Source:

module:lib/interfaces/common

Expose Progress.

Source:

module:lib/interfaces/common

Expose Spec.

Source:

module:lib/interfaces/common

Expose TAP.

Source:

module:lib/interfaces/common

Expose Text.

Source:

module:lib/interfaces/common

Expose XUnit.

Source:

module:lib/interfaces/common

Expose Suite.

Source:

module:lib/interfaces/common

Expose Doc.

Source:

(static) colors

Default color map.

Source:

(static) cursor

Expose some basic cursor interactions that are common among reporters.

Source:

(static) inlineDiffs

Inline diffs instead of +/-

Source:

(static) keys

Object.keys (<=IE8)

Source:

(static) symbols

Default symbol map.

Source:

(static) useColors

Enable coloring by default, except in the browser interface.

Source:

(static) utils

Expose internals.

Source:

(static) window

Expose term window size, with some defaults for when stderr is not a tty.

Source:

Methods

(static) canonicalize(value, stackopt) → {Object|Array|function|string|undefined}

Return a new Thing that has the keys in sorted order. Recursive.

If the Thing...

  • has already been seen, return string '[Circular]'
  • is undefined, return string '[undefined]'
  • is null, return value null
  • is some other primitive, return the value
  • is not a primitive or an Array, Object, or Function, return the value of the Thing's toString() method
  • is a non-empty Array, Object, or Function, return the result of calling this function again.
  • is an empty Array, Object, or Function, return the result of calling emptyRepresentation()
Parameters:
Name Type Attributes Default Description
value *

Thing to inspect. May or may not have properties.

stack Array <optional>
[]

Stack of seen values

Source:
See:
  • exports.stringify
Returns:
Type
Object | Array | function | string | undefined

(static) clean()

Strip the function definition from str, and re-indent for pre whitespace.

Source:

(static) create(parent, title) → {Suite}

Create a new Suite with the given title and parent Suite. When a suite with the same title is already present, that suite is returned to provide nicer reporter and more flexible meta-testing.

Parameters:
Name Type Description
parent Suite
title String
Source:
Returns:
Type
Suite

(static) escape(html) → {String}

Escape special characters in the given string of html.

Parameters:
Name Type Description
html String
Source:
Returns:
Type
String

(static) files() → {Array}

Lookup files in the given dir.

Source:
Returns:
Type
Array

(static) filter(array, fn)

Array#filter (<=IE8)

Parameters:
Name Type Description
array Array
fn function
Source:

(static) forEach(array, fn, scope)

Array#forEach (<=IE8)

Parameters:
Name Type Description
array Array
fn function
scope Object
Source:

(static) getError(err) → {Error}

Generate an undefined error if err is not defined.

Parameters:
Name Type Description
err Error
Source:
Returns:
Type
Error

(static) highlightTags(name)

Highlight the contents of tag name.

Parameters:
Name Type Description
name String
Source:

(static) indexOf(obj, start)

Array#indexOf (<=IE8)

Parameters:
Name Type Description
obj Object

to find index of

start Number
Source:

(static) isBuffer(arg) → {Boolean}

Return if obj is a Buffer

Parameters:
Name Type Description
arg Object
Source:
Returns:
Type
Boolean

(static) list(failures)

Outut the given failures as a list.

Parameters:
Name Type Description
failures Array
Source:

(static) lookupFiles()

Lookup file names at the given path.

Source:

(static) map(array, fn, scope)

Array#map (<=IE8)

Parameters:
Name Type Description
array Array
fn function
scope Object
Source:

(static) parseQuery(qs) → {Object}

Parse the given qs.

Parameters:
Name Type Description
qs String
Source:
Returns:
Type
Object

(static) reduce(array, fn, initial)

Array#reduce (<=IE8)

Parameters:
Name Type Description
array Array
fn function
initial Object

value

Source:

(static) slug(str) → {String}

Compute a slug from the given str.

Parameters:
Name Type Description
str String
Source:
Returns:
Type
String

(static) stackTraceFilter() → {function}

This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`)

When invoking this function you get a filter function that get the Error.stack as an input, and return a prettify output. (i.e: strip Mocha, node_modules, bower and componentJS from stack trace).

Source:
Returns:
Type
function

(static) stringify(value) → {string}

Stringify `value`.

Different behavior depending on type of value.

  • If value is undefined or null, return '[undefined]' or '[null]', respectively.
  • If value is not an object, function or array, return result of value.toString() wrapped in double-quotes.
  • If value is an empty object, function, or array, return result of function emptyRepresentation.
  • If value has properties, call exports.canonicalize on it, then return result of JSON.stringify().
Parameters:
Name Type Description
value *
Source:
See:
  • exports.type
Returns:
Type
string

(static) trim(str) → {String}

Trim the given str.

Parameters:
Name Type Description
str String
Source:
Returns:
Type
String

(static) type(value) → {string}

Takes some variable and asks {}.toString() what it thinks it is.

Parameters:
Name Type Description
value *

Anything

Source:
See:
Returns:
Type
string
Example
type({}) // 'object'
type([]) // 'array'
type(1) // 'number'
type(false) // 'boolean'
type(Infinity) // 'number'
type(null) // 'null'
type(new Date()) // 'date'
type(/foo/) // 'regexp'
type('type') // 'string'
type(global) // 'global'

(static) undefinedError() → {Error}

Generate an undefined error with a message warning the user.

Source:
Returns:
Type
Error

(static) watch(files, fn)

Watch the given files for changes and invoke fn(file) on modification.

Parameters:
Name Type Description
files Array
fn function
Source:

(inner) after()

Execute after running tests.

Source:

(inner) afterEach()

Execute after each test case.

Source:

(inner) before()

Execute before running tests.

Source:

(inner) beforeEach()

Execute before each test case.

Source:

(inner) runWithSuite()

This is only present if flag --delay is passed into Mocha. It triggers root suite execution. Returns a function which runs the root suite.

Source: