Constructor
new TestGroup(testName, …tests)
- Description:
- Creates a new test group to encapsulate multiple tests or nested groups.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
testName |
string | The name/title of this group. | |
tests |
TestBase |
<repeatable> |
Optional tests or nested groups to immediately add. |
Classes
Members
directFailureCount
- Description:
- Returns the number of direct failures of tests within the group. Note that a failure of the group itself is not counted.
- Source:
Returns the number of direct failures of tests within the group. Note that a failure of the group itself is not counted.
errorCount
- Description:
- The total number of errors found (including in nested groups).
- Source:
The total number of errors found (including in nested groups).
succeeded
- Description:
- Returns `true` if the test scucceeded (that is the value of `totalFailureCount` equals 0); otherwise, `false`.
- Source:
Returns `true` if the test scucceeded (that is the value of `totalFailureCount` equals 0); otherwise, `false`.
totalFailureCount
- Description:
- Returns the number of total failure count, including in inner groups. Note that a failure of the group itself is not counted.
- Source:
Returns the number of total failure count, including in inner groups. Note that a failure of the group itself is not counted.
unexpectedErrorCount
- Description:
- Returns the number of unexpected errors that were thrown.
- Source:
Returns the number of unexpected errors that were thrown.
Methods
add(…tests)
- Description:
- Adds tests or groups to this group.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tests |
TestBase |
<repeatable> |
One or more test/group instances. |
areEqual(testName, expected, actual, compareropt, thisArgopt) → {TestGroup}
- Description:
- Adds an equality assertion to the group. Checks if `actual === expected`, or uses a custom comparer if provided.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
testName |
string | Descriptive test title. | |
expected |
* | Expected value. | |
actual |
* | Actual value to compare. | |
comparer |
function |
<optional> |
Optional custom comparison function ((expected, actual) => boolean). |
thisArg |
any |
<optional> |
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
areNotEqual(testName, not_expected, actual, compareropt, thisArgopt) → {TestGroup}
- Description:
- Adds an inequality assertion to the group. Checks if `actual !== not_expected`, or uses a custom comparer if provided.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
testName |
string | Descriptive test title. | |
not_expected |
* | The value we're not expecting. | |
actual |
* | Actual value to compare. | |
comparer |
function |
<optional> |
Optional custom comparison function ((expected, actual) => boolean). |
thisArg |
any |
<optional> |
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
clear()
- Description:
- Clears all tests in this group.
- Source:
groupClose() → {TestGroup}
- Description:
- Ends the current group and returns its parent, if any. Enables fluid chaining of group nesting.
- Source:
Returns:
- The parent group or `this` if already root.
- Type
- TestGroup
groupStart(testName) → {TestGroup}
- Description:
- Begins a new nested group and automatically adds it to this group.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
testName |
string | The name of the nested group. |
Returns:
The new nested group.
- Type
- TestGroup
isDefined(testName, actual, thisArgopt) → {TestGroup}
- Description:
- Adds an assertion to the group that verifies a value is **not** `undefined`.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
testName |
string | Descriptive test title. | ||
actual |
* | Value to assert is defined. | ||
thisArg |
any |
<optional> |
null
|
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
isFalse(testName, actual, thisArgopt) → {TestGroup}
- Description:
- Adds an assertion to the group that verifies a value is `false`.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
testName |
string | Descriptive test title. | |
actual |
* | Value to assert is `false`. | |
thisArg |
any |
<optional> |
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
isNotNull(testName, actual, thisArgopt) → {TestGroup}
- Description:
- Adds an assertion to the group that verifies a value is **not** `null`.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
testName |
string | Descriptive test title. | ||
actual |
* | Value to assert is not `null`. | ||
thisArg |
any |
<optional> |
null
|
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
isNull(testName, actual, thisArgopt) → {TestGroup}
- Description:
- Adds an assertion to the group that verifies a value is strictly `null`.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
testName |
string | Descriptive test title. | |
actual |
* | Value to assert is `null`. | |
thisArg |
any |
<optional> |
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
isTrue(testName, actual, thisArgopt) → {TestGroup}
- Description:
- Adds an assertion to the group that verifies a value is `true`.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
testName |
string | Descriptive test title. | ||
actual |
* | Value to assert is `true`. | ||
thisArg |
any |
<optional> |
null
|
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
isUndefined(testName, actual, thisArgopt) → {TestGroup}
- Description:
- Adds an assertion to the group that verifies a value is strictly `undefined`.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
testName |
string | Descriptive test title. | ||
actual |
* | Value to assert is `undefined`. | ||
thisArg |
any |
<optional> |
null
|
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
noThrows(testName, fn, thisArgopt) → {TestGroup}
- Description:
- Adds an assertion that verifies a function does NOT throw.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
testName |
string | Descriptive test title. | ||
fn |
function | Function expected to execute without throwing. | ||
thisArg |
object |
<optional> |
null
|
Optional `this` binding for `fn`. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
run(write, mlAutoNumberopt) → {boolean}
- Description:
- Runs the test and optionally writes its result.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
write |
boolean | If true, writes the result to the console; If false doesn't write the result to the console; Otherwise writes only failures to the console. | |
mlAutoNumber |
MultiLevelAutoNumbering |
<optional> |
Optional multi-level automatic numbering to automatically prefix messages with numbers. |
Returns:
Whether the test passed.
- Type
- boolean
runImpl() → {boolean}
- Description:
- Executes all tests/groups in this group without printing. Aggregates error and timing info, but delays output if `write` is false.*
- Source:
Returns:
True if all direct tests succeeded.
- Type
- boolean
sequencesAreEqual(testName, expected, actual, {function(any,) → {TestGroup}
- Description:
- Adds a sequence equality assertion to the group. Compares two iterable sequences element-by-element.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
testName |
string | Descriptive test title. |
expected |
Iterable | The expected iterable sequence. |
actual |
Iterable | The actual iterable sequence. |
{function(any, |
any):boolean [itemComparer] - Optional custom item-level comparison function ((expected, actual) => boolean). |
Returns:
The current test group (for chaining).
- Type
- TestGroup
throws(testName, fn, checkErrorFnopt, thisArgopt) → {TestGroup}
- Description:
- Adds an assertion that verifies a function throws an error. Optionally verifies the error with a predicate.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
testName |
string | Descriptive test title. | ||
fn |
function | Function expected to throw. | ||
checkErrorFn |
function |
<optional> |
Optional predicate to inspect the thrown error. | |
thisArg |
any |
<optional> |
null
|
Optional context for evaluation. |
Returns:
The current test group (for chaining).
- Type
- TestGroup
write(mlAutoNumberopt)
- Description:
- Outputs a summary line and recursively logs all child test results. Uses collapsed group for passed tests and expanded group for failed ones.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
mlAutoNumber |
MultiLevelAutoNumbering |
<optional> |
Optional multi-level automatic numbering to automatically prefix messages with numbers. |