Search⌘ K
AI Features

Unit Testing

Explore how to write and run unit tests in Ember JS to ensure your services, such as the cart-service, behave as expected. Understand using QUnit and setupTest to create tests that validate methods and data handling in your web application.

Overview

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 ...