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(){
}
}
};
(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);
});
(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(){
});
});
});
module:lib/interfaces/common
Expose Mocha
.
(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 |
Returns:
- Type
- String | Number
module:lib/interfaces/common
Expose Pending
.
module:lib/interfaces/common
Expose Base
.
module:lib/interfaces/common
Expose Dot
.
module:lib/interfaces/common
Expose HTMLCov
.
module:lib/interfaces/common
Expose HTML
.
module:lib/interfaces/common
Expose JSONCov
.
module:lib/interfaces/common
Expose List
.
module:lib/interfaces/common
Expose JSON
.
module:lib/interfaces/common
Expose JUnit
.
module:lib/interfaces/common
Expose Landing
.
module:lib/interfaces/common
Expose List
.
module:lib/interfaces/common
Expose Markdown
.
module:lib/interfaces/common
Expose Min
.
module:lib/interfaces/common
Expose Dot
.
module:lib/interfaces/common
Expose Progress
.
module:lib/interfaces/common
Expose Spec
.
module:lib/interfaces/common
Expose TAP
.
module:lib/interfaces/common
Expose Text
.
module:lib/interfaces/common
Expose XUnit
.
module:lib/interfaces/common
Expose Runnable
.
module:lib/interfaces/common
Expose Runner
.
module:lib/interfaces/common
Expose Suite
.
module:lib/interfaces/common
Expose Test
.
module:lib/interfaces/common
Expose Doc
.
Members
module:lib/interfaces/common
Expose Mocha
.
module:lib/interfaces/common
Expose Base
.
module:lib/interfaces/common
Expose Dot
.
module:lib/interfaces/common
Expose HTMLCov
.
module:lib/interfaces/common
Expose HTML
.
module:lib/interfaces/common
Expose JSONCov
.
module:lib/interfaces/common
Expose List
.
module:lib/interfaces/common
Expose JSON
.
module:lib/interfaces/common
Expose JUnit
.
module:lib/interfaces/common
Expose Landing
.
module:lib/interfaces/common
Expose List
.
module:lib/interfaces/common
Expose Markdown
.
module:lib/interfaces/common
Expose Min
.
module:lib/interfaces/common
Expose Dot
.
module:lib/interfaces/common
Expose Progress
.
module:lib/interfaces/common
Expose Spec
.
module:lib/interfaces/common
Expose TAP
.
module:lib/interfaces/common
Expose Text
.
module:lib/interfaces/common
Expose XUnit
.
module:lib/interfaces/common
Expose Suite
.
module:lib/interfaces/common
Expose Doc
.
(static) colors
Default color map.
(static) cursor
Expose some basic cursor interactions that are common among reporters.
(static) inlineDiffs
Inline diffs instead of +/-
(static) keys
Object.keys (<=IE8)
(static) symbols
Default symbol map.
(static) useColors
Enable coloring by default, except in the browser interface.
(static) utils
Expose internals.
(static) window
Expose term window size, with some defaults for when stderr is not a tty.
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 valuenull
- is some other primitive, return the value
- is not a primitive or an
Array
,Object
, orFunction
, return the value of the Thing'stoString()
method - is a non-empty
Array
,Object
, orFunction
, return the result of calling this function again. - is an empty
Array
,Object
, orFunction
, return the result of callingemptyRepresentation()
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.
(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 |
Returns:
- Type
- Suite
(static) escape(html) → {String}
Escape special characters in the given string of html.
Parameters:
Name | Type | Description |
---|---|---|
html |
String |
Returns:
- Type
- String
(static) files() → {Array}
Lookup files in the given dir
.
Returns:
- Type
- Array
(static) filter(array, fn)
Array#filter (<=IE8)
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | |
fn |
function |
(static) forEach(array, fn, scope)
Array#forEach (<=IE8)
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | |
fn |
function | |
scope |
Object |
(static) getError(err) → {Error}
Generate an undefined error if err
is not defined.
Parameters:
Name | Type | Description |
---|---|---|
err |
Error |
Returns:
- Type
- Error
(static) highlightTags(name)
Highlight the contents of tag name
.
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
(static) indexOf(obj, start)
Array#indexOf (<=IE8)
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | to find index of |
start |
Number |
(static) isBuffer(arg) → {Boolean}
Return if obj is a Buffer
Parameters:
Name | Type | Description |
---|---|---|
arg |
Object |
Returns:
- Type
- Boolean
(static) list(failures)
Outut the given failures
as a list.
Parameters:
Name | Type | Description |
---|---|---|
failures |
Array |
(static) lookupFiles()
Lookup file names at the given path
.
(static) map(array, fn, scope)
Array#map (<=IE8)
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | |
fn |
function | |
scope |
Object |
(static) parseQuery(qs) → {Object}
Parse the given qs
.
Parameters:
Name | Type | Description |
---|---|---|
qs |
String |
Returns:
- Type
- Object
(static) reduce(array, fn, initial)
Array#reduce (<=IE8)
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | |
fn |
function | |
initial |
Object | value |
(static) slug(str) → {String}
Compute a slug from the given str
.
Parameters:
Name | Type | Description |
---|---|---|
str |
String |
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).
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 ofvalue.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 |
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.
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 |
(inner) after()
Execute after running tests.
(inner) afterEach()
Execute after each test case.
(inner) before()
Execute before running tests.
(inner) beforeEach()
Execute before each test case.
(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.