helpers

Unit.js provide several helpers methods. Helpers do not make assertions.

See also the guide of "helpers" for more details and examples.

Members

static stats :Object

Stats, see also stats in the guide.

Methods

case(expression)


It does nothing, is just pass-through method for a fluent chain. If a function is passed, it is called.

this scope is a reference to test.$di._container.

See also case() in the guide.

Parameters
Name Type Argument Description
expression
mixed
optional  repeatable 

Zero, one or more arguments.

Returns
Type Description
Object

The current UnitJS instance


See also

given(expression)


It does nothing, is just pass-through method for a fluent chain. If a function is passed, it is called.

this scope is a reference to test.$di._container.

See also given() in the guide.

Parameters
Name Type Argument Description
expression
mixed
optional  repeatable 

Zero, one or more arguments.

Returns
Type Description
Object

The current UnitJS instance


See also

when(expression)


It does nothing, is just pass-through method for a fluent chain. If a function is passed, it is called.

this scope is a reference to test.$di._container.

See also when() in the guide.

Parameters
Name Type Argument Description
expression
mixed
optional  repeatable 

Zero, one or more arguments.

Returns
Type Description
Object

The current UnitJS instance


See also

then(expression)


It does nothing, is just pass-through method for a fluent chain. If a function is passed, it is called.

this scope is a reference to test.$di._container.

See also then() in the guide.

Parameters
Name Type Argument Description
expression
mixed
optional  repeatable 

Zero, one or more arguments.

Returns
Type Description
Object

The current UnitJS instance


See also

if(expression)


It does nothing, is just pass-through method for a fluent chain.

this scope is a reference to test.$di._container.

See also if() in the guide.

Parameters
Name Type Argument Description
expression
mixed
optional  repeatable 

Zero, one or more arguments.

Returns
Type Description
Object

The current UnitJS instance


See also
and

and(expression)


It does nothing, is just pass-through method for a fluent chain.

this scope is a reference to test.$di._container.

See also and() in the guide.

Parameters
Name Type Argument Description
expression
mixed
optional  repeatable 

Zero, one or more arguments.

Returns
Type Description
Object

The current UnitJS instance


See also
if

wait(ms, fn)


Execute the given function after a specified number of milliseconds.

this scope is a reference to test.$di._container.

See also in the guide:

Parameters
Name Type Description
ms
number

The number of milliseconds to wait before executing the code.

fn
function

The function that will be executed.

Returns
Type Description
Object

The current UnitJS instance.

dump(value)


Dump the arguments. If no argument is passed, the actual tested value is dumped.

See also dump() in the guide.

Parameters
Name Type Argument Description
value
mixed
optional  repeatable 

Zero, one or more values to output. The string representations of each of these objects are appended together in the order listed and output.

Returns
Type Description
Object

The current control flow of unit testing.

fail(message, expected, actual, inspect)


Fails a test. See also fail() in the guide.

Parameters
Name Type Argument Description
message
string
optional 

Error message.

expected
mixed
optional 

Expected value.

actual
mixed
optional 

Actual value, by default the last value tested is used.

inspect
mixed
optional  repeatable 

Zero, one or more arguments to inspect in the console with the helper test.dump().

Throws
Type Description
AssertionError

Throws an AssertionError with the given arguments passed to the method fail().