Unit Testing

Learn about unit testing and how to create unit tests.


Unit tests check the correctness of individual methods and functions. They check for things such as whether a particular method returns the correct output for a given input. Unit tests can be used for route, controller, service, helper, model, adapter, serializer, and utils.

Unit tests for the cart-service

Let’s start with the unit test on the cart-service we created. When we create a service using the Ember CLI command, it automatically generates the service’s unit test file. All the tests are present in the tests directory of our main project folder. Let’s open the tests/unit/services/cart-service-tests.js file and see what it contains:

Get hands-on with 1200+ tech skills courses.