A Fixture is a class used to instantiate each test sub/case at run time. A new instance of the Fixture is created for every single test subcase (i.e. every time the test function is run).

Type Parameters

Hierarchy

Accessors

  • get sharedState(): S
  • Gets the test fixture's shared state. This object is shared between subcases within the same testcase.

    Returns S

Methods

  • Parameters

    • error: Promise<undefined | Error | (undefined | Error)[]>
    • __namedParameters: {
          mode?: "fail" | "warn";
      } = {}
      • Optional mode?: "fail" | "warn"

    Returns void

  • If the argument is an Error, fail (or warn). If it's undefined, no-op. If the argument is an array, apply the above behavior on each of elements.

    Parameters

    • error: undefined | Error | (undefined | Error)[]
    • __namedParameters: {
          mode?: "fail" | "warn";
          niceStack?: Error;
      } = {}
      • Optional mode?: "fail" | "warn"
      • Optional niceStack?: Error

    Returns void

  • Log an info message. Use sparingly. Use debug() instead if logs are only needed with debug logging enabled.

    Parameters

    • msg: string

    Returns void

  • Expect that the provided promise rejects, with the provided exception name.

    Parameters

    Returns void

  • Expect that the provided promise resolves (fulfills).

    Parameters

    • p: Promise<unknown>
    • Optional msg: string

    Returns void

  • Expect that the provided function throws (if true or string) or not (if false). If a string is provided, expect that the throw exception has that name.

    MAINTENANCE_TODO: Change to string | false so the exception name is always checked.

    Parameters

    • expectedError: string | boolean
    • fn: (() => void)
        • (): void
        • Returns void

    • __namedParameters: ExceptionCheckOptions = {}

    Returns void

  • Throws an exception marking the subcase as skipped if condition is true

    Parameters

    • cond: boolean
    • msg: string | (() => string) = ''

    Returns void

  • Tracks an object to be cleaned up after the test finishes.

    MAINTENANCE_TODO: Use this in more places. (Will be easier once .destroy() is allowed on invalid objects.)

    Type Parameters

    • T extends DestroyableObject

    Parameters

    • o: T

    Returns T

  • Tracks an object, if it's destroyable, to be cleaned up after the test finishes.

    Type Parameters

    • T

    Parameters

    • o: T

    Returns T

Generated using TypeDoc