Constructor
(abstract) new TestBase(testName, successMessageopt, failureMessageopt, additionalDataopt)
- Description:
- Base class for all test types. This class defines the common interface for test name, result summary, success/failure messages, optional data, and a way to log results.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
testName |
string | The name of the test (must be string). | ||
successMessage |
string |
<optional> |
"success"
|
Message when the test passes. |
failureMessage |
string |
<optional> |
"failure"
|
Message when the test fails. |
additionalData |
any |
<optional> |
Arbitrary data to show with test output. |
Members
additionalData
Gets extra information to log with the test.
additionalData
Sets extra information to log with the test.
elapsed
Gets the duration in milliseconds.
elapsed
Sets the time elapsed.
errorCount
Returns the count of errors (possibly from child tests)
errors
Returns the list of errors associated with the test.
failed
Returns whether the test failed (inverse of succeeded).
failureMessage
Returns the message to display on test failure.
logger
Returns the logger used to log test results.
name
Returns the name of the test.
succeeded
- Description:
- Returns whether the test passed — overridden in derived classes.
- Source:
Returns whether the test passed — overridden in derived classes.
succeeded
Sets a value indicating whether the test passed.
successMessage
Returns the message to display on test success.
Methods
run(write, mlAutoNumberopt) → {boolean}
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
(abstract) runImpl()
- Description:
- Runs the test without printing, just settings succeeded to the test result.
- Source:
write(mlAutoNumberopt)
- Description:
- Logs the result of the test to the console. If the test passes with no errors, it uses a flat `console.log`. If there are errors or additional data, it uses a collapsed group for clarity.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
mlAutoNumber |
MultiLevelAutoNumbering |
<optional> |
Optional multi-level automatic numbering to automatically prefix messages with numbers. |