You do not need to import the service. You must enable the service in need, as shown below.
moduleFor("controller:test", { needs: ['service:alias'] });
For example,
service / alias.js
Em.service.extend({ name: 'john' });
controllers / test.js
Em.Controller.extend({ alias: Em.service.inject(), test: function() { alert(this.get('alias.name'); } });
Tests / block / controllers / test-test.js
moduleFor('controller:test', { needs: ['service:store'] }); test('Alias Alias Alias', function(assert) { var controller = this.subject(); assert.equal(controller.get('store.name'), 'john); });
For this test, Ember will create a container with a controller test and service alias . This way, you can access the properties of the service with a name prefix.
siva - abc
source share