home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
1.13
  • Packages
    • ember
    • ember-application
    • ember-debug
    • ember-extension-support
    • ember-htmlbars
    • ember-metal
    • ember-routing
    • ember-routing-htmlbars
    • ember-routing-views
    • ember-runtime
    • ember-templates
    • ember-testing
    • ember-views
  • Namespaces
    • Ember
    • Ember.FEATURES
    • Ember.String
    • Ember.computed
    • Ember.inject
    • Ember.run
  • Classes
    • Ember.Application
    • Ember.Array
    • Ember.ArrayProxy
    • Ember.Binding
    • Ember.Checkbox
    • Ember.Component
    • Ember.ComputedProperty
    • Ember.ContainerDebugAdapter
    • Ember.Controller
    • Ember.ControllerMixin
    • Ember.CoreObject
    • Ember.DataAdapter
    • Ember.DefaultResolver
    • Ember.Error
    • Ember.Evented
    • Ember.Helper
    • Ember.InstrumentationSupport
    • Ember.Logger
    • Ember.Mixin
    • Ember.MutableArray
    • Ember.MutableEnumerable
    • Ember.Namespace
    • Ember.NativeArray
    • Ember.Object
    • Ember.Observable
    • Ember.PromiseProxyMixin
    • Ember.Route
    • Ember.Router
    • Ember.Service
    • Ember.Test
    • Ember.Test.Adapter
    • Ember.Test.QUnitAdapter
    • Ember.TextArea
    • Ember.TextField
    • Ember.VisibilitySupport
    • RSVP.EventTarget
    • RSVP.Promise

Class Ember.Test public


Defined in: packages/ember-testing/lib/test.js:15
Module: ember

This is a container for an assortment of testing related functionality:

  • Choose your default test adapter (for your framework of choice).
  • Register/Unregister additional test helpers.
  • Setup callbacks to be fired when the test helpers are injected into your application.


Methods

click (selector) : RSVP.Promise public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:262

selector
String

jQuery selector for finding element on the DOM

returns
RSVP.Promise

Clicks an element and triggers any actions triggered by the element's click event.

Example:

click('.some-jQuery-selector').then(function() {
  // assert something
});

currentPath : Object public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:444

Available since v1.5.0

returns
Object

The currently active path.

Returns the current path.

Example:

function validateURL() {
equal(currentPath(), 'some.path.index', "correct path was transitioned into.");
}

click('#some-link-id').then(validateURL);

currentRouteName : Object public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:424

Available since v1.5.0

returns
Object

The name of the currently active route.

Returns the currently active route name.

Example:

function validateRouteName() {
equal(currentRouteName(), 'some.path', "correct route was transitioned into.");
}

visit('/some/path').then(validateRouteName)

currentURL : Object public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:464

Available since v1.5.0

returns
Object

The currently active URL.

Returns the current URL.

Example:

function validateURL() {
equal(currentURL(), '/some/path', "correct URL was transitioned into.");
}

click('#some-link-id').then(validateURL);

fillIn (selector, text) : RSVP.Promise public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:341

selector
String

jQuery selector finding an input element on the DOM to fill text with

text
String

text to place inside the input element

returns
RSVP.Promise

Fills in an input element with some text.

Example:

fillIn('#email', 'you@example.com').then(function() {
  // assert something
});

find (selector) : Object public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:361

selector
String

jQuery string selector for element lookup

returns
Object

jQuery object representing the results of the query

Finds an element in the context of the app's container element. A simple alias for app.$(selector).

Example:

var $el = find('.my-selector');

findWithAssert (selector) : Object public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:378

selector
String

jQuery selector string for finding an element within the DOM

returns
Object

jQuery object representing the results of the query

Like find, but throws an error if the element selector returns no results.

Example:

var $el = findWithAssert('.doesnt-exist'); // throws error

injectTestHelpers public

Module: ember

Defined in packages/ember-testing/lib/test.js:402

This injects the test helpers into the helperContainer object. If an object is provided it will be used as the helperContainer. If helperContainer is not set it will default to window. If a function of the same name has already been defined it will be cached (so that it can be reset if the helper is removed with unregisterHelper or removeTestHelpers).

Any callbacks registered with onInjectHelpers will be called once the helpers have been injected.

Example:

App.injectTestHelpers();

keyEvent (selector, type, keyCode) : RSVP.Promise public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:320

Available since v1.5.0

selector
String

jQuery selector for finding element on the DOM

type
String

the type of key event, e.g. keypress, keydown, keyup

keyCode
Number

the keyCode of the simulated key event

returns
RSVP.Promise

Simulates a key event, e.g. keypress, keydown, keyup with the desired keyCode

Example:

keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() {
 // assert something
});

onInjectHelpers (callback) public

Module: ember

Defined in packages/ember-testing/lib/test.js:139

callback
Function

The function to be called.

Used to register callbacks to be fired whenever App.injectTestHelpers is called.

The callback will receive the current application as an argument.

Example:

Ember.Test.onInjectHelpers(function() {
  Ember.$(document).ajaxSend(function() {
    Test.pendingAjaxRequests++;
  });

  Ember.$(document).ajaxComplete(function() {
    Test.pendingAjaxRequests--;
  });
});

pauseTest : Object public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:484

Available since v1.9.0

returns
Object

A promise that will never resolve

Pauses the current test - this is useful for debugging while testing or for test-driving. It allows you to inspect the state of your application at any point.

Example (The test will pause before clicking the button):

visit('/')
return pauseTest();

click('.btn');

promise (resolver, label) public

Module: ember

Defined in packages/ember-testing/lib/test.js:167

resolver
Function

The function used to resolve the promise.

label
String

An optional string for identifying the promise.

This returns a thenable tailored for testing. It catches failed onSuccess callbacks and invokes the Ember.Test.adapter.exception callback in the last chained then.

This method should be returned by async helpers such as wait.

registerAsyncHelper (name, helperMethod) public

Module: ember

Defined in packages/ember-testing/lib/test.js:74

Available since v1.2.0

name
String

The name of the helper method to add.

helperMethod
Function

registerAsyncHelper is used to register an async test helper that will be injected when App.injectTestHelpers is called.

The helper method will always be called with the current Application as the first parameter.

For example:

Ember.Test.registerAsyncHelper('boot', function(app) {
  Ember.run(app, app.advanceReadiness);
});

The advantage of an async helper is that it will not run until the last async helper has completed. All async helpers after it will wait for it complete before running.

For example:

Ember.Test.registerAsyncHelper('deletePost', function(app, postId) {
  click('.delete-' + postId);
});

// ... in your test
visit('/post/2');
deletePost(2);
visit('/post/3');
deletePost(3);

registerHelper (name, helperMethod, options) public

Module: ember

Defined in packages/ember-testing/lib/test.js:37

name
String

The name of the helper method to add.

helperMethod
Function
options
Object

registerHelper is used to register a test helper that will be injected when App.injectTestHelpers is called.

The helper method will always be called with the current Application as the first parameter.

For example:

Ember.Test.registerHelper('boot', function(app) {
  Ember.run(app, app.advanceReadiness);
});

This helper can later be called without arguments because it will be called with app as the first parameter.

App = Ember.Application.create();
App.injectTestHelpers();
boot();

registerWaiter (context, callback) public

Module: ember

Defined in packages/ember-testing/lib/test.js:221

Available since v1.2.0

context
Object

(optional)

callback
Function

This allows ember-testing to play nicely with other asynchronous events, such as an application that is waiting for a CSS3 transition or an IndexDB transaction.

For example:

Ember.Test.registerWaiter(function() {
  return myPendingTransactions() == 0;
});

The context argument allows you to optionally specify the this with which your callback will be invoked.

For example:

Ember.Test.registerWaiter(MyDB, MyDB.hasPendingTransactions);

removeTestHelpers public

Module: ember

Defined in packages/ember-testing/lib/test.js:446

This removes all helpers that have been registered, and resets and functions that were overridden by the helpers.

Example:

App.removeTestHelpers();

resolve (The) public

Module: ember

Defined in packages/ember-testing/lib/test.js:205

Available since v1.2.0

The
Mixed

value to resolve

Replacement for Ember.RSVP.resolve The only difference is this uses an instance of Ember.Test.Promise

setupForTesting public

Module: ember

Defined in packages/ember-testing/lib/test.js:364

This hook defers the readiness of the application, so that you can start the app when your tests are ready to run. It also sets the router's location to 'none', so that the window's location will not be modified (preventing both accidental leaking of state between tests and interference with your testing framework).

Example:

App.setupForTesting();

triggerEvent (selector, context, type, options) : RSVP.Promise public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:504

Available since v1.5.0

selector
String

jQuery selector for finding element on the DOM

context
String

jQuery selector that will limit the selector argument to find only within the context's children

type
String

The event type to be triggered.

options
Object

The options to be passed to jQuery.Event.

returns
RSVP.Promise

Triggers the given DOM event on the element identified by the provided selector.

Example:

triggerEvent('#some-elem-id', 'blur');

This is actually used internally by the keyEvent helper like so:

triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 });

unregisterHelper (name) public

Module: ember

Defined in packages/ember-testing/lib/test.js:121

name
String

The helper to remove.

Remove a previously added helper method.

Example:

Ember.Test.unregisterHelper('wait');

unregisterWaiter (context, callback) public

Module: ember

Defined in packages/ember-testing/lib/test.js:258

Available since v1.2.0

context
Object

(optional)

callback
Function

unregisterWaiter is used to unregister a callback that was registered with registerWaiter.

visit (url) : RSVP.Promise public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:242

url
String

the name of the route

returns
RSVP.Promise

Loads a route, sets up any controllers, and renders any templates associated with the route as though a real user had triggered the route change while using your app.

Example:

visit('posts/index').then(function() {
  // assert something
});

wait (value) : RSVP.Promise public

Module: ember

Defined in packages/ember-testing/lib/helpers.js:396

value
Object

The value to be returned.

returns
RSVP.Promise

Causes the run loop to process any pending events. This is used to ensure that any async operations from other helpers (or your assertions) have been processed.

This is most often used as the return value for the helper functions (see 'click', 'fillIn','visit',etc).

Example:

```javascript Ember.Test.registerAsyncHelper('loginUser', function(app, username, password) { visit('secured/path/here') .fillIn('#username', username) .fillIn('#password', password) .click('.submit')

return app.testHelpers.wait(); });

Properties

adapter public

Module: ember

Defined in packages/ember-testing/lib/test.js:184

Used to allow ember-testing to communicate with a specific testing framework.

You can manually set it before calling App.setupForTesting().

Example:

Ember.Test.adapter = MyCustomAdapter.create()

If you do not set it, ember-testing will default to Ember.Test.QUnitAdapter.

testHelpers public

Module: ember

Defined in packages/ember-testing/lib/test.js:322

This property contains the testing helpers for the current application. These are created once you call injectTestHelpers on your Ember.Application instance. The included helpers are also available on the window object by default, but can be used from this object on the individual application also.

testing public

Module: ember

Defined in packages/ember-testing/lib/test.js:351

Available since v1.3.0

This property indicates whether or not this application is currently in testing mode. This is set when setupForTesting is called on the current application.

On this page


Methods

  • click
  • currentPath
  • currentRouteName
  • currentURL
  • fillIn
  • find
  • findWithAssert
  • injectTestHelpers
  • keyEvent
  • onInjectHelpers
  • pauseTest
  • promise
  • registerAsyncHelper
  • registerHelper
  • registerWaiter
  • removeTestHelpers
  • resolve
  • setupForTesting
  • triggerEvent
  • unregisterHelper
  • unregisterWaiter
  • visit
  • wait

Properties

  • adapter
  • testHelpers
  • testing
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.