API.md

October 9, 2021 · View on GitHub

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])

ParamTypeDescription
[name]stringThe test name.
[testFn]functionA function which will either succeed, reject or throw.
[options]objectTest config.
[options.timeout]numberA time limit for the test in ms.
[options.maxConcurrency]numberThe 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]booleanSkip this test.
[options.only]booleanOnly run this test.
[options.before]booleanRun this test before its siblings.
[options.after]booleanRun this test after its siblings.
[options.todo]booleanMark this test as incomplete.
[options.group]booleanMark 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

ParamTypeDescription
namestringTest name.
optionsobjectsConfig.

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

Add a test.

Kind: instance method of Tom

ParamTypeDescription
namestringTest name.
testFnfunctionTest function.
optionsobjectsConfig.

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

ParamTypeDescription
testTestObjectModelThe test node.

"skipped" (test)

Test skipped.

Kind: event emitted by Tom

ParamTypeDescription
testTestObjectModelThe test node.

"ignored" (test)

Test ignored.

Kind: event emitted by Tom

ParamTypeDescription
testTestObjectModelThe test node.

"in-progress" (test)

Test in-progress.

Kind: event emitted by Tom

ParamTypeDescription
testTestObjectModelThe test node.

"pass" (test, result)

Test pass.

Kind: event emitted by Tom

ParamTypeDescription
testTestObjectModelThe test node.
result*The value returned by the test.

"fail" (test, err)

Test fail.

Kind: event emitted by Tom

ParamTypeDescription
testTestObjectModelThe test node.
errErrorThe 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

ParamType
testsArray.<Tom>
[name]string

Tom.validate(tom) ⇒ boolean

Returns true if the input is a valid test.

Kind: static method of Tom

ParamTypeDescription
tomtest-object-modelInput 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