Test

Test

Test The main static interface for the moyal.js.test framework. Provides assertion utilities for test development and a central entry point to define and run tests. Also contains type utilities to assist in dynamic validation. Example usage: ```js Test.isTrue("Test if value is true", myValue); Test.areEqual("Value check", expected, actual); ```

Constructor

new Test()

Source:

Members

(static) Version

Description:
  • Returns the version of the test library. This is a read-only property used for diagnostics or compatibility checks.
Source:
Returns the version of the test library. This is a read-only property used for diagnostics or compatibility checks.

Methods

(static) areEqual(testName, expected, actual, compareropt, writeopt, nullable) → {boolean}

Description:
  • Asserts strict equality - 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).
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) areNotEqual(testName, not_expected, actual, compareropt, writeopt, nullable) → {boolean}

Description:
  • Asserts strict inequality - 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 not expecting.
actual * Actual value to compare.
comparer function <optional>
Optional custom comparison function ((not_expected, actual) => boolean).
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) isDefined(testName, actual, writeopt, nullable) → {boolean}

Description:
  • Asserts that specified value is **not** `undefined`.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
actual * Value to assert is defined.
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) isFalse(testName, actual, writeopt, nullable) → {boolean}

Description:
  • Asserts that specified value is strictly `false`.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
actual * Value to assert is `false`.
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) isNotNull(testName, actual, writeopt, nullable) → {boolean}

Description:
  • Asserts that the specified value is **not** `null`.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
actual * Value to assert is not `null`.
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) isNull(testName, actual, writeopt, nullable) → {boolean}

Description:
  • Asserts that the specfied value is strictly `null`.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
actual * Value to assert is `null`.
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) isTrue(testName, actual, writeopt, nullable) → {boolean}

Description:
  • Asserts that specified value is strictly `true`.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
actual * Value to assert is `true`.
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) isUndefined(testName, actual, writeopt, nullable) → {boolean}

Description:
  • Asserts that specified value is strictly `undefined`.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
actual * Value to assert is `undefined`.
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) noThrows(testName, fn, thisArgopt, writeopt, nullable) → {boolean}

Description:
  • Adds an assertion that verifies a function does NOT throw.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
fn function Function expected to execute without throwing.
thisArg object <optional>
Optional `this` binding for `fn`.
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) sequencesAreEqual(testName, expected, actual, itemCompareropt, writeopt, nullable) → {boolean}

Description:
  • Adds a sequence equality assertion to the group. Compares two iterable sequences element-by-element.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
expected Iterable The expected iterable sequence.
actual Iterable The actual iterable sequence.
itemComparer function <optional>
Optional custom item-level comparison function ((expected, actual) => boolean).
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean

(static) throws(testName, fn, checkErrorFnopt, thisArgopt, writeopt, nullable) → {boolean}

Description:
  • Adds an assertion that verifies a function throws an error. Optionally verifies the error with a predicate.
Source:
Parameters:
Name Type Attributes Description
testName string Descriptive test title.
fn function Function expected to throw.
checkErrorFn function <optional>
Optional predicate to inspect the thrown error.
thisArg object <optional>
Optional `this` binding for `fn` and `checkErrorFn`.
write boolean <optional>
<nullable>
The write mode: true - log all; false - don't log anything; null (or undefined) - log only errors.
Returns:
True if the test succeeded; otherwise, false.
Type
boolean