[Ember Integration tests] `this.register` rocks!


Let's assume that we have a service called foo that implements an API method called bar. We'll also assume that when you click on our components' a tag you trigger an action that calls the foo service's API.

Whoa, still with me?


Alright. Let's dive in!


moduleForComponent('some-thing',  {  
  integration: true,
    // extending in case the foo service has other responsibilities
    this.register('foo', FooService.extend({
      bar() { assert.ok(true); } 

test('blah', function(assert) {  

That wasn't so bad. We're simply ensuring that the FooService's bar API function gets called. I think this is a wonderful way to handle this.


Stubbing Services Ember.js Guides