Testing in Ember.js
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:
- A fullname attribute is computed which is the aggregate of its first and last.
- The serializer properly converts the blog request payload into a blog post model object.
- Blog dates are properly formatted.
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.
Examples of integration tests are:
- An author's full name and date are properly displayed in a blog post.
- A user is prevented from typing more than 50 characters into post's title field.
- Submitting a post without a title displays a red validation state on the field and gives the user text indicating that the title is required.
- The blog post list scrolls to position a new post at the top of the viewport.
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.
In the example scenario above, some acceptance tests one might write are:
- A user is able to log in via the login form.
- A user is able to create a blog post.
- After saving a new post successfully, a user is then shown the list of prior posts.
- A visitor does not have access to the admin panel.