Class Quench

The Quench class is the "hub" of the Quench module. It contains the primary public API for Quench, as well as references to the global mocha and chai objects.

Hierarchy

  • Quench

Properties

chai: ChaiStatic

Chai's static object

fc: __module

fast-check for property based testing

mocha: BrowserMocha

Mocha's browser global

reports: QuenchReports | Record<string, never> = {}

An object holding reports generated by the last run.

utils: {
    clearWorld: (() => Promise<void>);
    pause: ((millis) => Promise<void>);
}

Various utility functions

Type declaration

  • clearWorld: (() => Promise<void>)
      • (): Promise<void>
      • Resets the world to a blank state with no entities.

        WARNING: This will permanently delete every entity in your world (scenes, actors, items, macros, roll tables, journal entries, playlists, chat messages, folders, etc.)

        Returns Promise<void>

  • pause: ((millis) => Promise<void>)
      • (millis): Promise<void>
      • Pauses execution for the given number of milliseconds

        Parameters

        • millis: number

          duration to pause for in milliseconds

        Returns Promise<void>

        A Promise that is resolved when the given time passed

Methods

  • Aborts the currently running tests, if tests are currently running. Does nothing if no tests are currently running. This will not cancel an in progress test. The run will abort after the currently running test completes.

    Returns void

  • Registers a new Quench test batch which will show up in the quench window to be enabled/disabled and run.

    Suites and tests within a Quench test batch are not actually registered in the mocha runner until the user initiates the test run with runBatches. When runBatches is executed, the provided batches' registration functions are run and then the tests are executed.

    The registration function is passed a context argument, which contains the mocha and chai methods necessary for defining a test.

    • Mocha - describe, it, after, afterEach, before, beforeEach, and utils.
    • Chai - assert, expect, and should; the last one is also made available by extending Object.prototype.
    • fast-check - fc

    Parameters

    • key: `${string}.${string}`

      The test batch's unique string key. Only one test batch with a given key can exist at one time. If you register a test batch with a pre-existing key, it will overwrite the previous test batch.

    • fn: QuenchRegisterBatchFunction

      The function which will be called to register the suites and tests within your test batch.

    • context: QuenchRegisterBatchOptions = {}

      Additional options affecting Quench's handling of this batch.

    Returns void

    Example

    quench.registerBatch(
    "quench.examples.basic-pass",
    (context) => {
    const { describe, it, assert } = context;

    describe("Passing Suite", function () {
    it("Passing Test", function () {
    assert.ok(true);
    });
    });
    },
    {
    displayName: "QUENCH: Basic Passing Test",
    preSelected: true,
    snapBaseDir: "quench",
    },
    );
  • Runs the test batches defined by the keys in their registration.

    The contents of the test batches are registered with mocha when this function is executed.

    Parameters

    • Optional keys: string | string[] = "**"

      A single batch key or an array of batch keys to run.

      Simple wildcards are supported:

      • ? matches one arbitrary character, excluding the separator .
      • * matches zero or more arbitrary characters, excluding the separator .
      • ** matches zero or more arbitrary characters, including the separator .
    • Optional options: QuenchRunBatchOptions = {}

      Additional options affecting this batch run

    Returns Promise<Runner>

    Returns the mocha Runner object for this test run.

    Example

    Running all batches

    quench.runBatches(); // or
    quench.runBatches("**");

    Example

    Running a single batch

    quench.runBatches("quench.examples.basic-pass");
    

    Example

    Running multiple batches

    quench.runBatches(["quench.examples.basic-pass", "quench.examples.basic-fail"]);
    quench.runBatches("quench.examples.*"); // Will run "quench.examples.basic-pass", but not "quench.complex.basic-pass"

    Example

    Running all batches belonging to Quench

    quench.runBatches("quench.**"); // or
    quench.runBatches(["quench.**"]);

Generated using TypeDoc