TestBase

TestBase

BaseTest Abstract base class for all test types. Provides a unified interface for managing test name, success/failure status, timing, and output. Subclasses must override the `runImpl()` method to implement test logic.

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

Description:
  • Gets extra information to log with the test.
Source:
Gets extra information to log with the test.

additionalData

Description:
  • Sets extra information to log with the test.
Source:
Sets extra information to log with the test.

elapsed

Description:
  • Gets the duration in milliseconds.
Source:
Gets the duration in milliseconds.

elapsed

Description:
  • Sets the time elapsed.
Source:
Sets the time elapsed.

errorCount

Description:
  • Returns the count of errors (possibly from child tests)
Source:
Returns the count of errors (possibly from child tests)

errors

Description:
  • Returns the list of errors associated with the test.
Source:
Returns the list of errors associated with the test.

failed

Description:
  • Returns whether the test failed (inverse of succeeded).
Source:
Returns whether the test failed (inverse of succeeded).

failureMessage

Description:
  • Returns the message to display on test failure.
Source:
Returns the message to display on test failure.

logger

Description:
  • Returns the logger used to log test results.
Source:
Returns the logger used to log test results.

name

Description:
  • Returns the name of the test.
Source:
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

Description:
  • Sets a value indicating whether the test passed.
Source:
Sets a value indicating whether the test passed.

successMessage

Description:
  • Returns the message to display on test success.
Source:
Returns the message to display on test success.

Methods

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

(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.