Introduction Edit Page


Testing is a core part of the Ember framework and its development cycle.

Let's assume you are writing an Ember application which will serve as a blog. This application would likely include models such as user and post. It would also include interactions such as login and create post. Let's finally assume that you would like to have automated tests in place for your application.

There are three different classifications of tests that you will need: Acceptance, Unit, and Integration.

Acceptance Tests

Acceptance tests are used to test user interaction and application flow. The tests interact with the application in the same ways that a user would, by doing things like filling out form fields and clicking buttons. Acceptance tests ensure that the features within a project are basically functional, and are valuable in ensuring the core features of a project have not regressed, and that the project's goals are being met.

In the example scenario above, some acceptance tests one might write are:

Unit Tests

Unit tests are used to test isolated chunks of functionality, or "units". They can be written against any isolated application logic.

Some specific examples of units tests are:

Integration Tests

Integration tests serve as a middle ground between acceptance tests, which only interact with the full system through user endpoints, and unit tests, which interact with specific code algorithms on a micro level. Integration tests verify interactions between various parts of the application, such as behavior between UI controls. They are valuable in ensuring data and actions are properly passed between different parts of the system, and provide confidence that parts of the system will work within the application under multiple scenarios.

It is recommended that components be tested with integration tests because the component interacts with the system in the same way that it will within the context of the application, including being rendered from a template and receiving Ember's lifecycle hooks.

Examples of integration tests are:

Testing Frameworks

QUnit is the default testing framework for this guide, but others are supported through third-party addons.

How to Run Your Tests

Run your tests with ember test on the command-line. You can re-run your tests on every file-change with ember test --server.

Tests can also be executed when you are running a local development server (started by running ember server), at the /tests URI which renders the tests/index.html template. A word of caution using this approach: Tests run using ember server have the environment configuration development, whereas tests executed under ember test --server are run with the configuration test. This could cause differences in execution, such as which libraries are loaded and available. Therefore its recommended that you use ember test --server for test execution.

These commands run your tests using Testem to make testing multiple browsers very easy. You can configure Testem using the testem.js file in your application root.