Quench
    Preparing search index...

    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.

    Index

    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: number) => Promise<void>;
    }

    Various utility functions

    Type declaration

    • clearWorld: () => Promise<void>
    • pause: (millis: number) => Promise<void>

    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

      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

      • Optionalkeys: 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 .
      • Optionaloptions: QuenchRunBatchOptions = {}

        Additional options affecting this batch run

      Returns Promise<Runner>

      Returns the mocha Runner object for this test run.

      quench.runBatches(); // or
      quench.runBatches("**");
      quench.runBatches("quench.examples.basic-pass");
      
      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"
      quench.runBatches("quench.**"); // or
      quench.runBatches(["quench.**"]);