Testing — The Three Layers

Unit, Rendering & Application

Testing — The Three Layers

Ember ships with three test types out of the box — unit, rendering, and application. Each layer tests a different slice of your app.

4 min read Level 2/5 #ember#testing#qunit
What you'll learn
  • Differentiate the three test layers
  • Pick the right layer for each test
  • Run tests with ember test or ember test --server

Ember bakes testing into the framework. Every new app comes with a test runner, three test types, and DOM helpers — zero setup.

The Three Layers

LayerFolderPurpose
Unittests/unit/Plain modules — helpers, services
Renderingtests/integration/A component in isolation
Applicationtests/acceptance/Whole-app flows: visit, click, etc

Each layer has a matching setup helper from ember-qunit: setupTest, setupRenderingTest, setupApplicationTest.

Pick the Right Layer

  • Unit — for logic with no DOM. A util function, a service method, a computed value.
  • Rendering — for component output and interaction. Fast, focused, and the layer you will write the most of.
  • Application — for end-to-end flows that span routes. Slowest, so reserve for critical paths.

Run the Suite

ember test               # one-shot CI run
ember test --server      # watch mode, browser UI at :7357
ember test --filter foo  # only tests matching "foo"

The Testem runner launches a real browser (Chrome by default) and reports results inline.

Generate a Test

ember g component-test my-card     # rendering test
ember g service-test cart          # unit test
ember g acceptance-test signup     # acceptance test
Unit Tests →