Skip to content

Latest commit

 

History

History
373 lines (264 loc) · 14.3 KB

API.md

File metadata and controls

373 lines (264 loc) · 14.3 KB

Modules

test-object-model

Classes

TestContext

The test context, available as this within each test function.

test-object-model

Tom ⏏

Kind: Exported class

new Tom([name], [testFn], [options])

Param Type Description
[name] string The test name.
[testFn] function A function which will either succeed, reject or throw.
[options] object Test config.
[options.timeout] number A time limit for the test in ms.
[options.maxConcurrency] number The max concurrency that child tests will be able to run. For example, specifying 2 will allow child tests to run two at a time. Defaults to 10.
[options.skip] boolean Skip this test.
[options.only] boolean Only run this test.
[options.before] boolean Run this test before its siblings.
[options.after] boolean Run this test after its siblings.
[options.todo] boolean Mark this test as incomplete.
[options.group] boolean Mark this test as a group.

tom.name : string

Test name

Kind: instance property of Tom

tom.testFn : function

A function which will either succeed, reject or throw.

Kind: instance property of Tom

tom.index : number

Position of this test within its parents children

Kind: instance property of Tom

tom.ended : boolean

True if the test has ended.

Kind: instance property of Tom

tom.result : *

If the test passed, the value returned by the test function. If it failed, the exception thrown or rejection reason.

Kind: instance property of Tom

tom.disabledByOnly : boolean

True if one or more different tests are marked as only.

Kind: instance property of Tom

tom.options

The options set when creating the test.

Kind: instance property of Tom

tom.context : TextContext

The text execution context.

Kind: instance property of Tom

tom.state : string

Test state. Can be one of pending, in-progress, skipped, ignored, todo, pass or fail.

Kind: instance property of Tom

tom.type ⇒ string

Returns test, group or todo.

Kind: instance property of Tom

tom.toSkip ⇒ booolean

Returns true if this test was marked to be skipped by usage of skip or only.

Kind: instance property of Tom

tom.stats : object

Test execution stats

Kind: instance namespace of Tom

tom.toString() ⇒ string

Returns the test name.

Kind: instance method of Tom

tom.group(name, options) ⇒ Tom

Add a test group.

Kind: instance method of Tom

Param Type Description
name string Test name.
options objects Config.

tom.test(name, testFn, options) ⇒ Tom

Add a test.

Kind: instance method of Tom

Param Type Description
name string Test name.
testFn function Test function.
options objects Config.

tom.skip() ⇒ Tom

Add a skipped test

Kind: instance method of Tom

tom.only() ⇒ Tom

Add an only test

Kind: instance method of Tom

tom.before() ⇒ Tom

Add a test which must run and complete before the others.

Kind: instance method of Tom

tom.todo() ⇒ Tom

Add a test but don't run it and mark as incomplete.

Kind: instance method of Tom

tom.after() ⇒ Tom

Add a test which must run and complete after the others.

Kind: instance method of Tom

tom.run() ⇒ Promise

Execute the stored test function. Return a promise that either resolves with the value returned by the test function or rejects.

Kind: instance method of Tom
Fulfil: *

tom.reset()

Reset state

Kind: instance method of Tom

tom.getTestCount()

Used in the @test-runner/core stats.

Kind: instance method of Tom

"todo" (test)

Test todo.

Kind: event emitted by Tom

Param Type Description
test TestObjectModel The test node.

"skipped" (test)

Test skipped.

Kind: event emitted by Tom

Param Type Description
test TestObjectModel The test node.

"ignored" (test)

Test ignored.

Kind: event emitted by Tom

Param Type Description
test TestObjectModel The test node.

"in-progress" (test)

Test in-progress.

Kind: event emitted by Tom

Param Type Description
test TestObjectModel The test node.

"pass" (test, result)

Test pass.

Kind: event emitted by Tom

Param Type Description
test TestObjectModel The test node.
result * The value returned by the test.

"fail" (test, err)

Test fail.

Kind: event emitted by Tom

Param Type Description
test TestObjectModel The test node.
err Error The exception thrown.

Tom.combine(tests, [name]) ⇒ Tom

If more than one TOM instances are supplied, combine them into a common root.

Kind: static method of Tom

Param Type
tests Array.<Tom>
[name] string

Tom.validate(tom) ⇒ boolean

Returns true if the input is a valid test.

Kind: static method of Tom

Param Type Description
tom test-object-model Input to test.

Tom~start : number

Start time.

Kind: inner property of Tom

Tom~end : number

End time.

Kind: inner property of Tom

Tom~duration : number

Test execution duration.

Kind: inner property of Tom

TestContext

The test context, available as this within each test function.

Kind: global class

testContext.name

The name given to this test.

Kind: instance property of TestContext

testContext.index

The test index within the current set.

Kind: instance property of TestContext

testContext.data

Test run data.

Kind: instance property of TestContext