Application.inject is not a function in initializer unit test

This Initializer seems to be working as far the actual application goes but when I go to run the unit test for it I always get an error.

TypeError: application.inject is not a function

Any help would be greatly appreciated. Thanks :smile:


export function initialize(application) {
application.inject('adapter', 'language', 'service:language');

export default {
    name: 'language',
    initialize: initialize


import Ember from 'ember';
import { initialize } from '../../../initializers/language';
import { module, test } from 'qunit';

var registry;
var application;

module('Unit | Initializer | language', {
    beforeEach: function() { {
		application = Ember.Application.create();
		registry = application.registry;

// Replace this with your real tests.
test('it works', function(assert) {
    initialize(registry, application);

    // you would normally confirm the results of the initializer here

i am getting the same error and would also appreciate an answer to this. In general I find initializers and injection difficult to grok.

one thing i just noticed is that the arguments being passed to initialize are not correct.

//in initializer
export function initialize(application) {

//in test
initialize(registry, application);

when ember cli generates this stuff you get something like this in the initializer:

export function initialize(/* container, application */) {

the application itself only seems to call the initializer with application as an argument.

now, i’ve just started using ember but my guess is that in Ember 2 that is the way it should be called, but the CLI still generates the old style invocation, since it is at an earlier version.

any ideas?


Have you resolved this problem?