Module test

A test runner compliant to the CommonJS Unit Testing specification.

Functions


getStackTrace (trace)

Creates a stack trace and parses it for display.

Parameters

java.lang.StackTraceElement trace The trace to parse. If not given a stacktrace will be generated

Returns

String The parsed stack trace

getType (obj)

Returns the type of the object passed as argument. This is heavily inspired by http://philrathe.com/articles/equiv and tlrobinson's narwhal test module (http://github.com/tlrobinson/narwhal/)

Parameters

obj

Returns

String The type of the object passed as argument

jsDump (value, lvl)

Converts the value passed as argument into a nicely formatted and indented string

Parameters

Object value The value to convert into a string
Number lvl Optional indentation level (defaults to zero)

Returns

String The string representation of the object passed as argument

jsDump.indent (lvl)

Parameters

lvl

jsDump.quote (str)

Parameters

str

run (scope, name, writer)

The main runner method. This method can be called with one, two or three arguments: run(scope), run(scope, nameOfTest), run(scope, writer) or run(scope, nameOfTest, writer)

Parameters

String|Object scope Either the path to a module containing unit tests to execute, or an object containing the exported test methods or nested scopes.
String name Optional name of a test method to execute
Object writer Optional writer to use for displaying the test results. Defaults to TermWriter.