ember-test-waiters

  • Version 2.1.3
  • Published
  • 53.3 kB
  • 4 dependencies
  • MIT license

Install

npm i ember-test-waiters
yarn add ember-test-waiters
pnpm add ember-test-waiters

Overview

The default blueprint for ember-cli addons.

Index

Functions

function buildWaiter

buildWaiter: (name: string) => TestWaiter;
  • Builds and returns a test waiter. The type of the returned waiter is dependent on whether the app or addon is in DEBUG mode or not.

    Parameter name

    The name of the test waiter

    Returns

    {TestWaiter}

    Example 1

    import Component from '@ember/component'; import { buildWaiter } from '@ember/test-waiters';

    if (DEBUG) { let waiter = buildWaiter('friend-waiter'); }

    export default class Friendz extends Component { didInsertElement() { let token = waiter.beginAsync(this);

    someAsyncWork().then(() => { waiter.endAsync(token); }); } }

    Modifiers

    • @public

function getPendingWaiterState

getPendingWaiterState: () => PendingWaiterState;
  • Gets the current state of all waiters. Any waiters whose waitUntil method returns false will be considered pending.

    Returns

    {PendingWaiterState} An object containing a count of all waiters pending and a waiters object containing the name of all pending waiters and their debug info.

function getWaiters

getWaiters: () => Waiter[];
  • Gets an array of all waiters current registered.

    Returns

    {Waiter[]}

    Modifiers

    • @public

function hasPendingWaiters

hasPendingWaiters: () => boolean;
  • Determines if there are any pending waiters.

    Returns

    {boolean} true if there are pending waiters, otherwise false.

function register

register: (waiter: Waiter) => void;
  • Registers a waiter.

    Parameter waiter

    A test waiter instance

    Modifiers

    • @public

function unregister

unregister: (waiter: Waiter) => void;
  • Un-registers a waiter.

    Parameter waiter

    A test waiter instance

    Modifiers

    • @public

function waitForPromise

waitForPromise: <T, KindOfPromise extends unknown>(
promise: KindOfPromise,
label?: string
) => KindOfPromise;
  • A convenient utility function to simplify waiting for a promise.

    Parameter promise

    The promise to track async operations for

    Parameter label

    An optional string to identify the promise

    Example 1

    import Component from '@ember/component'; import { waitForPromise } from '@ember/test-waiters';

    export default class Friendz extends Component { didInsertElement() { waitForPromise(new Promise(resolve => { doSomeWork(); resolve(); })); } }

    Modifiers

    • @public

Interfaces

interface PendingWaiterState

interface PendingWaiterState {}
  • PendingWaiterState

    Modifiers

    • @public

property pending

pending: number;

    property waiters

    waiters: {
    [waiterName: string]: TestWaiterDebugInfo[] | true;
    };

      interface TestWaiter

      interface TestWaiter<T extends object | Primitive | unknown = Token>
      extends Waiter {}
      • TestWaiter

        Modifiers

        • @public

      method beginAsync

      beginAsync: (token?: T, label?: string) => T;
      • Should be used to signal the beginning of an async operation that is to be waited for. Invocation of this method should be paired with a subsequent endAsync call to indicate to the waiter system that the async operation is completed.

        beginAsync

        Parameter item

        The item to register for waiting

        Parameter label

        An optional label to identify the item

        Modifiers

        • @public

      method endAsync

      endAsync: (token: T) => void;
      • Should be used to signal the end of an async operation. Invocation of this method should be paired with a preceding beginAsync call from this instance, which would indicate the beginning of an async operation.

        endAsync

        Parameter item

        The item to that was registered for waiting

        Modifiers

        • @public

      method reset

      reset: () => void;
      • Resets the waiter state, clearing items tracking async operations in this waiter.

        reset

        Modifiers

        • @public

      interface TestWaiterDebugInfo

      interface TestWaiterDebugInfo {}
      • TestWaiterDebugInfo

        Modifiers

        • @public

      property label

      label: string | undefined;

        property stack

        stack: string | undefined;

          interface Waiter

          interface Waiter {}
          • Waiter

            Modifiers

            • @public

          property name

          name: WaiterName;
          • A string representing the test waiter name.

            name {WaiterName}

            Modifiers

            • @public

          method debugInfo

          debugInfo: () => TestWaiterDebugInfo[];
          • Returns the debugInfo for each item tracking async operations in this waiter.

            debugInfo

            Returns

            {TestWaiterDebugInfo}

            Modifiers

            • @public

          method waitUntil

          waitUntil: () => boolean;
          • Used to determine if the waiter system should still wait for async operations to complete.

            waitUntil

            Returns

            {boolean}

            Modifiers

            • @public

          Type Aliases

          type Primitive

          type Primitive = string | number | boolean | symbol | bigint;
          • Primitive

            Any of the primitive value types

          type Token

          type Token = Primitive | unknown;
          • Token

          type WaiterName

          type WaiterName = string;
          • WaiterName

            A string representing the test waiter name

          Namespaces

          namespace ember-test-waiters/templates/*

          module 'ember-test-waiters/templates/*' {}

            variable tmpl

            const tmpl: any;

              namespace qunit

              module 'qunit' {}

                variable module

                const module: any;

                  variable only

                  const only: any;

                    variable skip

                    const skip: any;

                      variable test

                      const test: any;

                        variable todo

                        const todo: any;

                          Package Files (7)

                          Dependencies (4)

                          Dev Dependencies (37)

                          Peer Dependencies (0)

                          No peer dependencies.

                          Badge

                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ember-test-waiters.

                          • Markdown
                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ember-test-waiters)
                          • HTML
                            <a href="https://www.jsdocs.io/package/ember-test-waiters"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>