ember-qunit

  • Version 9.0.1
  • Published
  • 63.9 kB
  • 3 dependencies
  • MIT license

Install

npm i ember-qunit
yarn add ember-qunit
pnpm add ember-qunit

Overview

QUnit helpers for testing Ember.js applications

Index

Functions

function setResolver

setResolver: (resolver: Resolver) => void;
  • Sets a Resolver globally which will be used to look up objects from each test's container.

function setupApplicationTest

setupApplicationTest: (hooks: NestedHooks, options?: SetupTestOptions) => void;
  • Sets up acceptance tests.

    The setupApplicationTest function is used for all acceptance tests. It is invoked in the callback scope of a QUnit module (aka "nested module").

    Once invoked, all subsequent hooks.beforeEach and test invocations will have access to the following: * this.owner - the owner object that been set on the test context. * this.pauseTest and this.resumeTest - allow easy pausing/resuming of tests. * this.element which returns the DOM element representing the application's root element.

function setupEmberOnerrorValidation

setupEmberOnerrorValidation: () => void;

    function setupRenderingTest

    setupRenderingTest: (hooks: NestedHooks, options?: SetupTestOptions) => void;
    • Sets up tests that need to render snippets of templates.

      The setupRenderingTest method is used for tests that need to render snippets of templates. It is also invoked in the callback scope of a QUnit module (aka "nested module").

      Once invoked, all subsequent hooks.beforeEach and test invocations will have access to the following: * All of the methods / properties listed for setupTest * this.render(...) - Renders the provided template snippet returning a promise that resolves once rendering has completed * An importable render function that de-sugars into this.render will be the default output of blueprints * this.element - Returns the native DOM element representing the element that was rendered via this.render * this.$(...) - When jQuery is present, executes a jQuery selector with the current this.element as its root

    function setupTest

    setupTest: (hooks: NestedHooks, options?: SetupTestOptions) => void;
    • Sets up tests that do not need to render snippets of templates.

      The setupTest method is used for all types of tests except for those that need to render snippets of templates. It is invoked in the callback scope of a QUnit module (aka "nested module").

      Once invoked, all subsequent hooks.beforeEach and test invocations will have access to the following: * this.owner - This exposes the standard "owner API" for the test environment. * this.set / this.setProperties - Allows setting values on the test context. * this.get / this.getProperties - Retrieves values from the test context.

    function start

    start: (options?: QUnitStartOptions) => void;

      Classes

      class QUnitAdapter

      class QUnitAdapter extends EmberTestAdapter {}

        Interfaces

        interface SetupTestOptions

        interface SetupTestOptions {}
        • Options for configuring the test runner. Normally, you will not need to customize this. It is exported primarily so that end user app code can name it when passing it back to the framework.

        property resolver

        resolver?: Resolver | undefined;
        • The resolver to use when instantiating container-managed entities in the test.

        Namespaces

        namespace global

        namespace global {}

          interface NestedHooks

          interface NestedHooks {}

            method after

            after: <TC extends TestContext>(
            fn: (this: TC, assert: Assert) => void | Promise<void>
            ) => void;
            • Runs after the last test. If additional tests are defined after the module's queue has emptied, it will not run this hook again.

            method afterEach

            afterEach: <TC extends TestContext>(
            fn: (this: TC, assert: Assert) => void | Promise<void>
            ) => void;
            • Runs after each test.

            method before

            before: <TC extends TestContext>(
            fn: (this: TC, assert: Assert) => void | Promise<void>
            ) => void;
            • Runs before the first test.

            method beforeEach

            beforeEach: <TC extends TestContext>(
            fn: (this: TC, assert: Assert) => void | Promise<void>
            ) => void;
            • Runs before each test.

            interface QUnit

            interface QUnit {}

              method only

              only: <TC extends TestContext>(
              name: string,
              callback: (this: TC, assert: Assert) => void | Promise<unknown>
              ) => void;
              • Adds a test to exclusively run, preventing all other tests from running.

                Use this method to focus your test suite on a specific test. QUnit.only will cause any other tests in your suite to be ignored.

                Note, that if more than one QUnit.only is present only the first instance will run.

                This is an alternative to filtering tests to run in the HTML reporter. It is especially useful when you use a console reporter or in a codebase with a large set of long running tests.

                Parameter name

                Title of unit being tested

                Parameter callback

                Function to close over assertions

              method skip

              skip: <TC extends TestContext>(
              name: string,
              callback?: (this: TC, assert: Assert) => void | Promise<unknown>
              ) => void;
              • Adds a test like object to be skipped.

                Use this method to replace QUnit.test() instead of commenting out entire tests.

                This test's prototype will be listed on the suite as a skipped test, ignoring the callback argument and the respective global and module's hooks.

                Parameter name

                Title of unit being tested

                Parameter callback

                Function to close over assertions

              method todo

              todo: <TC extends TestContext>(
              name: string,
              callback: (this: TC, assert: Assert) => void | Promise<unknown>
              ) => void;
              • Use this method to test a unit of code which is still under development (in a “todo” state). The test will pass as long as one failing assertion is present.

                If all assertions pass, then the test will fail signaling that QUnit.todo should be replaced by QUnit.test.

                Parameter name

                Title of unit being tested

                Parameter callback

                Function to close over assertions

              namespace global.QUnit

              namespace global.QUnit {}

                interface EachFunction

                interface EachFunction {}

                  call signature

                  <TC extends TestContext, T>(
                  name: string,
                  dataset: T[],
                  callback: (this: TC, assert: Assert, data: T) => void | Promise<unknown>
                  ): void;

                    interface OnlyFunction

                    interface OnlyFunction {}

                      call signature

                      <TC extends TestContext>(
                      name: string,
                      callback: (this: TC, assert: Assert) => void | Promise<unknown>
                      ): void;

                        interface SkipFunction

                        interface SkipFunction {}

                          call signature

                          <TC extends TestContext>(
                          name: string,
                          callback?: (this: TC, assert: Assert) => void | Promise<unknown>
                          ): void;

                            interface TestFunction

                            interface TestFunction {}

                              call signature

                              <TC extends TestContext>(
                              name: string,
                              callback: (this: TC, assert: Assert) => void | Promise<unknown>
                              ): void;

                                interface TodoFunction

                                interface TodoFunction {}

                                  call signature

                                  <TC extends TestContext>(
                                  name: string,
                                  callback?: (this: TC, assert: Assert) => void | Promise<unknown>
                                  ): void;

                                    Package Files (1)

                                    Dependencies (3)

                                    Dev Dependencies (23)

                                    Peer Dependencies (3)

                                    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-qunit.

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