ember-qunit
- Version 8.1.0
- Published
- 61.4 kB
- 4 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
Classes
Interfaces
Namespaces
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
andthis.resumeTest
- allow easy pausing/resuming of tests. *this.element
which returns the DOM element representing the application's root element.
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 test
test: <TC extends TestContext>( name: string, callback: (this: TC, assert: Assert) => void | Promise<unknown>) => void;
Add a test to run.
Add a test to run using
QUnit.test()
.The
assert
argument to the callback contains all of QUnit's assertion methods. Use this argument to call your test assertions.QUnit.test()
can automatically handle the asynchronous resolution of a Promise on your behalf if you return a thenable Promise as the result of your callback function.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 byQUnit.test
.Parameter name
Title of unit being tested
Parameter callback
Function to close over assertions
Package Files (1)
Dependencies (4)
Dev Dependencies (23)
- @babel/core
- @babel/eslint-parser
- @ember/test-helpers
- @embroider/addon-dev
- @glimmer/component
- @release-it-plugins/lerna-changelog
- @rollup/plugin-babel
- @tsconfig/ember
- @types/qunit
- @types/rsvp
- concurrently
- ember-source
- eslint
- eslint-config-prettier
- eslint-plugin-disable-features
- eslint-plugin-node
- eslint-plugin-prettier
- expect-type
- prettier
- qunit
- release-it
- rollup
- typescript
Peer Dependencies (3)
Badge
To add a badge like this oneto 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>
- Updated .
Package analyzed in 2909 ms. - Missing or incorrect documentation? Open an issue for this package.