What does this.subject() do in ember-cli?

I see that every generated test from ember-cli uses this.subject(). I read the ember-cli docs and it says:

“this.subject() calls the factory for the object specified by the fullname and will return an instance of the object.”

Does that mean that Ember calls the create method on the service/component/etc under test with the fullname specified in moduleFor?

moduleFor('service:auth', 'Unit | Service | auth', {});
test('auth exists', function(assert) {
  var auth = this.subject();

So for this test, would the fullname be “service:auth”? Where can I find more on that fullname convention? I think I might be googling the wrong terms. Thanks in advance!

1 Like

@skaterdav85 I think this comes from the test helper callbacks. See here https://github.com/switchfly/ember-test-helpers/blob/master/lib/ember-test-helpers/test-module-for-component.js#L68

So what “subject” is depends on context.

The fullname argument is the “string” key of the object as it is registered on the ember application container. It generally follows a type:name convention.


  • service:auth
  • model:user
  • route:home
  • controller:home
  • component:my-button


More info on containers in Ember: